Thread: [htmltmpl] Executing code after print $template->output
Brought to you by:
samtregar
From: John <jo...@e-...> - 2004-05-10 15:38:46
|
Hi everyone BACKGROUND I'm using H::T with mod_perl and want to run some slow (several seconds) of code at the end of a script, and after the user receives his HTTP response. I have tried doing the following: print $template->output; $r->register_cleanup(\&some_stuff); sub some_stuff() { sleep 10; #for example } Expecting to receive the template page while the sub routine "some_stuff" does its thing. However, H:T seems to wait till "some_stuff" finishes before going to work. AND NOW THE QUESTION(S) So is there any way of getting H::T to get to work before the script calling the ->output method finishes ? What exactly does H::T wait for before swapping the tags anyway ? An alternative (and maybe off topic) question would be, if H::T must wait till the script calling the output method finishes before executing, does anyone know of a way to get the results I am looking for without forking ? Cheers John --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.680 / Virus Database: 442 - Release Date: 09/05/2004 |
From: Sam T. <sa...@tr...> - 2004-05-10 17:20:55
|
On Mon, 10 May 2004, John wrote: > I have tried doing the following: > > print $template->output; > $r->register_cleanup(\&some_stuff); I don't know much about register_cleanup() but I have used PerlCleanupHandler for this kind of thing with success. Looking at the docs for register_cleanup() it's not clear to me that it runs the code after the response is sent to the client. Just what is a "pool" anyway? > However, H:T seems to wait till "some_stuff" finishes before going to > work. I doubt it. Try this to see if you're right: print $template->output; warn("HTML::Template output complete."); $r->register_cleanup(\&some_stuff); If you get that warning in your logs before the sleep() starts then HTML::Template is done and your problem lies elsewhere. I suggest you post a question to the mod_perl mailing-list where the mod_perl gurus can give you a better answer than mine. -sam |
From: Todd <htm...@ch...> - 2004-05-10 17:40:04
|
Trying closing STDOUT after the call to output. -Todd On Mon, May 10, 2004 at 05:38:45PM +0200, John wrote: > Hi everyone > > BACKGROUND > > I'm using H::T with mod_perl and want to run some slow (several seconds) > of code at the end of a script, and after the user receives his HTTP > response. > > I have tried doing the following: > > print $template->output; > $r->register_cleanup(\&some_stuff); > > > sub some_stuff() { > sleep 10; #for example > } > > Expecting to receive the template page while the sub routine > "some_stuff" does its thing. > > However, H:T seems to wait till "some_stuff" finishes before going to > work. > > AND NOW THE QUESTION(S) > > So is there any way of getting H::T to get to work before the script > calling the ->output method finishes ? > > What exactly does H::T wait for before swapping the tags anyway ? > > An alternative (and maybe off topic) question would be, if H::T must > wait till the script calling the output method finishes before > executing, does anyone know of a way to get the results I am looking for > without forking ? > > Cheers > > John > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.680 / Virus Database: 442 - Release Date: 09/05/2004 > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Sleepycat Software > Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to > deliver higher performing products faster, at low TCO. > http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Sam T. <sa...@tr...> - 2004-05-10 18:07:37
|
On Mon, 10 May 2004, Todd wrote: > Trying closing STDOUT after the call to output. You really don't want to do that in mod_perl... -sam |
From: Philip T. <phi...@gm...> - 2004-05-11 01:45:33
|
Sometime on May 10, Sam Tregar assembled some asciibets to say: > On Mon, 10 May 2004, Todd wrote: > > > Trying closing STDOUT after the call to output. > > You really don't want to do that in mod_perl... What about $|=1? -- 'My strength is like the strength of ten because my heart is pure,' said Carrot. 'Really? Well, there's eleven of them.' (Jingo) |