0

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.

Amandasaurus
  • 31,471
  • 65
  • 192
  • 253

1 Answers1

2

Use gdb to work out why it crashes. See:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Debugging_Crashes_With_GDB

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.

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19