running subprocess.Popen under apache+mod_wsgi is always returning an error with a returncode of -6

ぃ、小莉子 提交于 2019-12-09 03:08:58

问题


I'm hoping someone's seen this -

I'm running django-compressor, taking advantage of the lessc setup to render/compress the less into CSS on the file. It works perfectly when invoked from the development server, but when run underneath apache+mod_wsgi it is consistently returning an error.

To debug this, I have run the exact command that the filter is invoking as the www-data user (which is defined as the wsgi user in the WSGIDaemonProcess directive) and verified that it works correctly, including permissions to read and write the files that it's manipulating.

I have also hacked on the django-compressor code in compressor/filters/base.py on that system, and it seems that ANY command attempting to get invoked is getting a returncode of -6 after the proc.communicate() invocation.

I'm hoping someone's seen this before - or that it rings some bell. It works fine on this machine outside of the apache+mod_wsgi process (i.e. running the process as a dev server) as well. I'm just not clear on what might be blocking the subprocess.Popen() invocations.


回答1:


Are you using Python 2.7.2 by chance?

That version of Python introduced a bug which cause fork() in sub interpreters to fail:

http://bugs.python.org/issue13156

You will have to force WSGI application to run in main Python interpreter of the process by setting:

WSGIApplicationGroup %{GLOBAL}

If running multiple Django applications you need to ensure that only the one affected has this configuration directive applied to it else you would cause all Django applications to run in one interpreter which isn't possible due to how Django configuration works.



来源:https://stackoverflow.com/questions/8494335/running-subprocess-popen-under-apachemod-wsgi-is-always-returning-an-error-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!