Long running "background" operations?

2 views
Skip to first unread message

Thomas Matysik

unread,
Jun 12, 2008, 6:52:25 PM6/12/08
to pylons-...@googlegroups.com

Is there a way to “background” a long operation; ie return a response to the user while leaving it running?

 

I have an (infrequently used) operation that needs to be launched from a web request that can take several hours, and I’d like it to not crash when the browser or Apache get tired of waiting for a response.

 



__________ Information from ESET NOD32 Antivirus, version of virus signature database 3182 (20080612) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Shannon -jj Behrens

unread,
Jun 12, 2008, 9:48:58 PM6/12/08
to pylons-...@googlegroups.com
On Thu, Jun 12, 2008 at 3:52 PM, Thomas Matysik <tho...@belton.co.nz> wrote:
> Is there a way to "background" a long operation; ie return a response to the
> user while leaving it running?
>
> I have an (infrequently used) operation that needs to be launched from a web
> request that can take several hours, and I'd like it to not crash when the
> browser or Apache get tired of waiting for a response.

This is a pretty common question. I'm guessing that the archives have
lots of different, good answers.

You can always spawn a thread or fork the process. Make sure the
initial request is responded to immediately, and then use AJAX to
contact the server looking for updates. Back before AJAX was popular,
I use to just set a META tag telling the status page to reload every
30 seconds. That worked too. You just need to a way for the worker
thread or process to notify the Web server thread of its state.
That's a typical computer science problem.

Happy Hacking!
-jj

--
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

Reply all
Reply to author
Forward
0 new messages