【发布时间】:2016-08-25 21:36:28
【问题描述】:
所以我有一组 python 脚本。为了制作一个简单的 GUI,我一直在结合 html 和 CGI。到目前为止,一切都很好。但是,我的一个脚本需要很长时间才能完成(> 2 小时)。很明显,当我在我的服务器(mac 上的本地主机)上运行它时,我得到一个“网关超时错误”。我正在阅读有关分叉子流程并检查该流程是否完成的信息。
这是我想出的,但它不起作用:(。
import os, time
#upstream stuff happening as part of main script
pid=os.fork()
if pid==0:
os.system("external_program") #this program will make "text.txt" as output
exit()
while os.stat(""text.txt").st_size == 0: # check whether text.txt has been written, if not print "processing" and continue to wait
print "processing"
sys.stdout.flush()
time.sleep(300)
#downstream stuff happening
一如既往,感谢任何帮助
【问题讨论】:
标签: python subprocess cgi