Python subprocess.Popen在uWSGI下运行缓慢

Cam*_*ron 4 python performance popen uwsgi

我在Fedora 14上设置了一个运行Cherokee的开发服务器,使用uWSGI与我的WSGI应用程序连接.

当应用程序被第一个请求命中时,我产生了一个这样的过程:

from subprocess import Popen
Popen(['bash'])  # bash is just an example; the problem happens with all programs
Run Code Online (Sandbox Code Playgroud)

第一个请求需要10-15秒才能完成(后续请求需要不到一秒钟).如果没有创建Popen对象,第一个请求只需要2-3秒即可完成.当我从Python shell执行相同的Popen请求时,它是即时的.

什么可能导致这种行为?我错过了一些明显的事吗?

小智 11

--close-on-exec

否则,您的新进程将继承套接字

(这是UNIX标准行为)