python子进程Popen在apache CGI调用时意外地阻塞父进程

python子进程Popen在apache CGI调用时意外地阻塞父进程,python,apache,subprocess,cgi,Python,Apache,Subprocess,Cgi,我在ApacheServer2.4上有一个由CGI脚本调用的python任务(run.py)。 我正在使用Python2.7.11,操作系统“FedoraRelease23(二十三版)” 在run.py中,我有 p = subprocess.Popen([sys.executable,"main.py"],stdout=subprocess.PIPE) return "Your task has been launched" 我想使用Popen启动一个非阻塞过程,并获得即时返回 但问题是,它阻

我在ApacheServer2.4上有一个由CGI脚本调用的python任务(run.py)。 我正在使用Python2.7.11,操作系统“FedoraRelease23(二十三版)”

在run.py中,我有

p = subprocess.Popen([sys.executable,"main.py"],stdout=subprocess.PIPE)
return "Your task has been launched"
我想使用Popen启动一个非阻塞过程,并获得即时返回

但问题是,它阻碍了程序。在main.py完成之前,run.py不会返回。有人知道为什么波本的行为和医生说的不一样吗

我也试过了

subprocess.Popen([sys.executable,"main.py"],stdout=subprocess.PIPE,close_fds=True)
subprocess.Popen([sys.executable,"main.py"],stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
subprocess.Popen([sys.executable,"main.py"],stdout=None,stderr=None)
所有这些都不起作用

更多信息:

在我的旧apache服务器2.2版中,同样的代码可以正常工作。 这个问题是否与apache服务器配置文件(httpd.conf)有关

现在我能想到的新服务器和旧服务器的区别是:

新服务器:

python 2.7.11, os Fedora release 23 (Twenty Three), new installed apache 2.4 (httpd.conf almost all default)
旧服务器:

python 2.7.3, os Fedora release 17 (Beefy Miracle), apache 2.2 (httpd.conf have lots of lines then new server)
有什么线索吗?非常感谢

编辑:

我忘了提到,在新服务器中,我在test.py中编写了代码,并使用命令行“python test.py”将其调用。它工作正常,得到了即时返回和后台运行的子进程,apache服务器内部肯定有一些有趣的东西