I noticed that the python cgi script displays the output only after it has completed its execution, Is there a way, I could make the script to continue its execution and print the results continously. I found that If I run the script "abc.py" as such in Apache, then output is displayed continously (script continuing its execution), however on calling script from another script doesn't works.
Below is the code :- (abc.py)
import sys, time
#sys.stdout.write('Content-Type: text/html;charset=utf-8\r\n\r\n')
#print '<html><body>'
for i in range(10):
print '<div>%i</div>'%i
sys.stdout.flush()
time.sleep(1)
I want to run this script from another CGI script. Now when I am calling this script (in Apache using below script), the output is printed only after its completion. Is there a way to fix it.
print 'Content-Type: text/html;charset=utf-8\r\n\r\n'
print '<html><body>'
PIPE = subprocess.PIPE
pd = subprocess.Popen(['abc.py'],
stdout=PIPE, stderr=PIPE)
stdou, stder = pd.communicate()
sys.stdout.write(stdou)
sys.stdout.flush()
</html>tag to render the output?