Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
My django application that used to make some shell commands by using python subprocess.Popen does not work anymore since I upgrade to ubuntu to 11.10
To simplify the problem, I put the faulty code into the wsgi script :
import os
import sys
from subprocess import Popen,PIPE
p=Popen(['/usr/bin/id'],stdout=PIPE,stderr=PIPE)
comm=p.communicate()
print comm,p.returncode
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
If I run this code directly by python, it works :
$ python -V
Python 2.7.2+
$ python django_wsgi.py
('uid=1002(www) gid=1002(www) groups=1002(www)\n', '') 0
If I run this code by apache (I just put the relevant URL into a browser), in the apache log, I got :
[Tue Nov 29 11:34:38 2011] [error] ('', '') -6
What is this error '-6' ???
The problem is that with my development server (Ubuntu 10.04, almost the same apache/wsgi version, same apache configuration file, same environment variables, but with python 2.6.5) it works well :
[Tue Nov 29 11:29:10 2011] [error] ('uid=1000(www) gid=1000(www) groups=1000(www)\\n', '') 0
Do you know why Popen is not work through apache anymore with python 2.7 ?
Because latest Python 2.7 has a bug in it which causes fork run in sub interpreters to fail.
http://bugs.python.org/issue13156
Presuming only hosting the one WSGI application, force use of the main interpreter rather than a sub interpreter by adding to your Apache configuration:
WSGIApplicationGroup %{GLOBAL}
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.