Thread and CGI

Gustavo Cordova gcordova at hebmex.com
Fri Feb 15 10:07:40 EST 2002


> 
> Hi All,
> 
> The CGI I request run on a long time displaying regulary a 
> point for the advance. If I stop the page with the "stop
> button in IE", I stop the job !!
> So I would like to print "Your job is in background now. 
> Thanks for your request."
> 
> The Thread approch is may be an alternative ??
> 
> Have you examples of thread approach if it is good one or 
> others tips ?
> 
> FR
> 

What I did once, when I had such a problem (maybe a bit
worse, because in my case the browser timed-out) was to
send the message to the browser, "thank you, an acknowledge
will be sent to you shortly", re-open all standard
filehandles (stdin, stdout, stderr) to "/dev/null",
and then fork.

The parent process then exits, and the child process lowers
it's priority, and does the work. Upon finishing, it
dispatches an email to the used with the acknowledgment.

It worked pretty nicely :-)

Remember:
	REOPEN STDIN, STDOUT, STDERR TO /dev/null !!!!

I know this is a python group, but I originally did this
in perl, so I'm posting the bit I used:

Because, if not, the child won't "daemonize", and the
parent process will hang until the child finishes, or
the browser times-out (upon which the child will be
summarily terminated).

Good luck!

-gustavo




More information about the Python-list mailing list