Get cgi script to begin execution of another script...

sophie_newbie paulgeeleher at gmail.com
Wed Mar 12 12:43:33 EDT 2008


I've posted something similar to this already, but now I'm more sure
of what I'm asking.

Basically I've a CGI script, that when executed by the user, I want to
call another script that does a very long running task (10 hours +)
and print a message on the screen saying that the user will be emailed
on completion of the very long task. The script executing the very
long task will then email the user on completion.

So far I have something like this (leaving out the obvious)...

CGI script:

pid = subprocess.Popen(["python", "spawn.py"]).pid
print "Thanks you will be emailed on completion"


Spawn.py script:

doVeryLongCalc()
emailUser()


Basically the problem with this is that the cgi script page in the
browser keeps on acting as if its loading until the Spawn.py script is
finished executing. Somehow apache "knows" that the spawned process is
still running in the background. So I'm basically asking if I can
somehow spawn a script that will be completely independent of its
parent script? So Apache doesn't know its running and the page
finishes loading?

Thanks if anyone can help...



More information about the Python-list mailing list