2017-05-24 37 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) 

回答