I am trying to execute a long-running python 2.7 cgi script asynchronously and return a complete html to the browser so it does not time out (and without waiting for the script to complete)... I am running on Windows XAMPP and abbreviated code is below
My problem is the browser still waits until the entire script is complete... Am I doing something wrong? I've read other similar questions and they comment that adding stdout and stderr arguments might fix the issue, but it has not for me... I also tried setting close_fds=True and eliminate the stdout/sterr arguments and that did not work either... script.py works fine standalone and does not have any output...
Or is there another approach you would recommend? Thank you for any help you can provide!
#!c:\program files\anaconda2\python.exe
import cgi
import subprocess
import sys
subprocess.Popen([sys.executable, 'c:/path/script.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print 'Content-type:text/html\r\n\r\n'
print '<html>'
print '<head></head>'
print '<body></body>'