python cgi webpage won't redirect before background children processes finish

Yingjie Lin Yingjie.Lin at mssm.edu
Tue Feb 22 17:01:39 EST 2011


Hi all,

I have a python cgi script which looks like this:

[CODE STARTING HERE]
open('xxxxxxxxx')
print 'Content-Type: text/html\n\n'
......
print '<meta http-equiv="refresh" content="15;url=%s">' % myURL
......
### after printing the webpage
os.system('python myfile.py')
logfile.write('END OF SCRIPT')
logfile.close()
[CODE ENDING]

Question: I want this cgi webpage to automatically redirect to myURL after 15 seconds. 
As soon as the execution of this script finishes, the corresponding job disappears from 
ps command output, the webpage is displayed and the log file is written. However, the 
webpage doesn't redirect after 15 seconds unless the background child process 
'python myfile.py' finishes by then.

Is this problem caused by initialing the children job through os.system() ? Does any one 
know what I need to change to make the redirection work before background children processes finish?

Thank you very much!

Yingjie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110222/2081e3fa/attachment.html>


More information about the Python-list mailing list