Re: [Persistentperl-users] Indefinite wait on first pass through?
Brought to you by:
samh
From: Sam H. <sa...@da...> - 2003-02-14 18:17:21
|
The five minute hang is probably a file that is being held onto either by your perl script, or by a process you spawn (like oracle). The five minutes isn't being consumed by one part of your code or the other, it's the web server thinking that your code is still running even after it's done, because you still have an open file. At least that's my best guess from what I've seen so far. If you could start tearing parts of your code out in testing, like remove the oracle database open altogether, or remove other parts where you may dup files or spawn other processes, and see if the hang goes away, you could probably narrow it down that way, to see which part is causing it. To answer your question, here's what your main program should look like: #!/usr/bin/perperl &log("step1"); $query = new CGI; &log("step2"); &process_request(); &log("step3"); No while loop is required. There's no need to call exit. If your script is written correctly you should be able to switch from "perperl" to "perl" with no changes to the code. > Hi Sam, > > Todd & I have narrowed down the issue a bit, but we could still use your advice. We added > timing/debug/log statements to our core software and it revealed a few things. It is not really an > Oracle issue. I think it is more related to how we get and process the CGI request and if our main > program should ever exit(0)? Here's what we've found: > > 1) background info: a small version of our code is: > #!/usr/bin/perperl -X -- -M1 -t604800 > MAIN: > { > &log("step1"); > $query = new CGI; > > &log("step2"); > &process_request(); > > &log("step3"); > # exit(0); > } > > sub process_request > { > .... our main application here... > } > > where process_request(); is the bulk of our program. > > It flies through steps 1,2,3 within 1-3 seconds.... then after step3, it hangs for 5 minutes... if we > add the exit(0), it still hangs... > > If we recraft the code to be: > MAIN: > { > &log("step1"); > > while(1) { > $query = new CGI; > &log("step2"); > > &process_request(); > &log("step3"); > } > } > > Then it processes the first request over & over again, but really quickly.... > > If we recraft the code to be: > MAIN: > { > &log("step1"); > > while($query = new CGI) { > &log("step2"); > > &process_request(); > &log("step3"); > } > } > > Then it takes the long time to process even the first request... > > My guess is that we should be putting this into a loop or not using "new CGI" but using something like > CGI::Request() or something. Can you e-mail us a 5 line sample script on what you had in mind? I'm > sure it's some confusion about how the main loop should either poll forever, or exit and what CGI:: > method you (the perperl code) is expecting us to use. > > Many thanks, > > Joel > > > ______________________________________ > Joel Plotkin > eJournalPress > http://www.ejournalpress.com > 301-254-5900 > 301-564-4006 (fax) > > > > > > --------------87E8EBFE6E648645532F8BFB > Content-Type: text/html; charset=us-ascii > Content-Transfer-Encoding: 7bit > > <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> > <html> > Hi Sam, > <p>Todd & I have narrowed down the issue a bit, but we could still > use your advice. We added timing/debug/log statements to our core > software and it revealed a few things. It is not really an Oracle > issue. I think it is more related to how we get and process the CGI > request and if our main program should ever exit(0)? Here's what > we've found: > <p>1) background info: a small version of our code is: > <br>#!/usr/bin/perperl -X -- -M1 -t604800 > <br><tt>MAIN:</tt> > <br><tt>{</tt> > <br><tt> &log("step1");</tt> > <br><tt> $query = new CGI;</tt><tt></tt> > <p><tt> &log("step2");</tt> > <br><tt> &process_request();</tt><tt></tt> > <p><tt> &log("step3");</tt> > <br><tt> # exit(0);</tt> > <br><tt>}</tt><tt></tt> > <p><tt>sub process_request</tt> > <br><tt>{</tt> > <br><tt>.... our main application here...</tt> > <br><tt>}</tt> > <p>where process_request(); is the bulk of our program. > <p>It flies through steps 1,2,3 within 1-3 seconds.... then after step3, > it hangs for 5 minutes... if we add the exit(0), it still hangs... > <p>If we recraft the code to be: > <br><tt>MAIN:</tt> > <br><tt>{</tt> > <br><tt> &log("step1");</tt><tt></tt> > <p><tt> while(1) {</tt> > <br><tt> $query = new CGI;</tt> > <br><tt> &log("step2");</tt><tt></tt> > <p><tt> &process_request();</tt> > <br><tt> &log("step3");</tt> > <br><tt> }</tt> > <br><tt>}</tt> > <p>Then it processes the first request over & over again, but really > quickly.... > <p>If we recraft the code to be: > <br><tt>MAIN:</tt> > <br><tt>{</tt> > <br><tt> &log("step1");</tt><tt></tt> > <p><tt> while($query = new CGI) {</tt> > <br><tt> &log("step2");</tt><tt></tt> > <p><tt> &process_request();</tt> > <br><tt> &log("step3");</tt> > <br><tt> }</tt> > <br><tt>}</tt> > <p>Then it takes the long time to process even the first request... > <p>My guess is that we should be putting this into a loop or not using > "new CGI" but using something like CGI::Request() or something. Can > you e-mail us a 5 line sample script on what you had in mind? I'm > sure it's some confusion about how the main loop should either poll forever, > or exit and what CGI:: method you (the perperl code) is expecting us to > use. > <p>Many thanks, > <p>Joel > <br> > <p>______________________________________ > <br>Joel Plotkin > <br>eJournalPress > <br><A HREF="http://www.ejournalpress.com">http://www.ejournalpress.com</A> > <br>301-254-5900 > <br>301-564-4006 (fax) > <br> > <br> > <br> > <br> </html> > > --------------87E8EBFE6E648645532F8BFB-- > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: FREE SSL Guide from Thawte > are you planning your Web Server Security? Click here to get a FREE > Thawte SSL guide and find the answers to all your SSL security issues. > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en > _______________________________________________ > Persistentperl-users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/persistentperl-users > |