--- Louis-David Mitterrand <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> Were are trying to run long a task (DB import) from a HTML::Mason
> page and are trying to send an immediate response to the user while
> the task is running. Here is our pseudo-code:
> 
> <%init>
> sub long_running_task {
>       # lottsa long, boring stuff
> }
> $r->puch_handlers(PerlCleanupHandler=>\&long_running_task($myarg));
> </%init>
>
> The rest of the page sends back HTML. The problem is that it _not_
> sent back until the long_running_task function has completed.
> 
> I thought that when registering a code ref in that way the sub{}
> would not be called until later during the PerlCleanupHandler phase.
> 
> Am I missing something, is there a better way to do it?
> 
> Thanks in advance for your insight,

Since you're pushing that handler onto the cleanup phase, I'm assuming
that you don't mean to send any more data to the client. It sounds like
the buffer isn't getting flushed (though I can't imagine why). Maybe if
you flush it manually? "local $|=1" or something?

I've had this problem in cases where I wanted to fork a long running
subprocess, because the child's STDIN and STDOUT are still pegged to
the browser socket. For a child, it works pretty well to close and
reopen the STD' filehandles to dissociate from the client after the
fork (like running a daemon).

Would that do for what you need here?
 
> -- 
>  HIPPOLYTE: Quelques crimes toujours précèdent les grands crimes.
>             Quiconque a pu franchir les bornes légitimes
>             Peut violer enfin les droits les plus sacrés ;
>                                           (Phèdre, J-B Racine, acte
> 4, scène 2)

...since I don't have a copy of Phaedra on my desk, would you translate
this for me?  My French is nowhere near good enough for this one. ;o]

Cheers, and good luck.

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/

Reply via email to