2017-05-24 58 views
0

我有一个CGI表单,它需要一个CSV表和电子邮件,并调用在后台运行的两个单独的python脚本。这些需要大约15分钟的时间来执行。我想对这些脚本进行异步调用,以便我可以显示一些消息并防止apache超时。如何使多个异步调用python cgi脚本

这里是我的代码

import os 
import cgi, cgitb 
import csv 
import sys 
import subprocess 
import io 

cgitb.enable() 
form = cgi.FieldStorage() 
filedata = form['file'] 
filecontent = filedata.file.read().splitlines() 
email=form.getvalue('email_address') 

email = str(email) 



subprocess.Popen([sys.executable, 'giw.py', str(email)], shell=False, 
stdin=None, stdout=None, stderr=None, close_fds=True) 


subprocess.Popen([sys.executable, 'mailer.py', str(email)], shell=False, 
stdin=None, stdout=None, stderr=None, close_fds=True) 

回答