I want to use the python setproctitle module to update the process name of a python WSGI worker process when it starts working on a request. (This is to try to track down what URLs are using all the CPU). I have written a simple Django middleware class that will call setproctitle.setproctitle(request.path). This works fine in the django debug server (i.e. python manage.py runserver), i.e. I can see the request URL in the output of top.

However when I try to run the same code using apache & mod_wsgi the wsgi process segfaults when it loads the middleware python file. It segfaults at the import setproctitle line. (print statements before that line are executed, but not after).

Is it possible to get setproctitle working with wsgi?

The server is Ubuntu Linux, using apache, mod_wsgi, and django.


Use gdb to work out why it crashes. See:


If that doesn't help you to work out problem yourself, then suggest you post all the details to the mod_wsgi mailing list as this site doesn't work well when needing to iteratively debug a problem.

Also try forcing use of main Python interpreter using:

WSGIApplicationGroup %{GLOBAL}

It may be the case that setproctitle module doesn't work properly in sub interpreters, although I can't see why it wouldn't as it should just be a wrapper for a single function and should be pretty simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.