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

S

sophie_newbie

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...
 
S

Sion Arrowsmith

sophie_newbie said:
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.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
was helpful to me in solving this problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top