My django application that accustomed to have spend instructions by utilizing python subprocess.Popen doesn't work any longer since i have upgrade to ubuntu to 11.10

To simplify the issue, I place the faulty code in to 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()

Basically run this code directly by python, it really works :

$ python -V
Python 2.7.2+
$ python django_wsgi.py 
('uid=1002(www) gid=1002(www) groups=1002(www)\n', '') 0

Basically run this code by apache (I simply place the relevant URL right into a browser), within the apache log, I acquired :

[Tue Nov 29 11:34:38 2011] [error] ('', '') -6

What's this error '-6' ???

However , with my development server (Ubuntu 10.04, almost exactly the same apache/wsgi version, same apache configuration file, same atmosphere variables, however with python 2.6.5) it really works well :

[Tue Nov 29 11:29:10 2011] [error] ('uid=1000(www) gid=1000(www) groups=1000(www)\\n', '') 0

Are you aware why Popen isn't sort out apache any longer with python 2.7 ?

Because latest Python 2.7 includes a bug inside it which in turn causes fork run in sub interpreters to fail.

http://bugs.python.org/issue13156

Supposing only hosting the main one WSGI application, pressure utilisation of the primary interpreter as opposed to a sub interpreter with the addition of for your Apache configuration:

WSGIApplicationGroup %{GLOBAL}