The problem is that WSGI servers will use multiple processes and detach or redirect the standard streams - in, out, and shake it all about err.
For Apache httpd and mod_wsgi:
- Start with
apachectl -X, not apachectl start (nor service apache2 start, etc.)
- Do not use
WSGIDaemonProcess, WSGIProcessGroup, etc.
You may need to add WSGIPythonHome, WSGIPythonPath, etc. to replace the daemon properties.
Similarly, for gunicorn you need the settings debug=True and daemon=False.
The mod_wsgi guide recommends wrapping wsgi.application with a class, invoking pdb at the start of every request, but any other traps should work.
class Debugger:
def __init__(self, object):
self.__object = object
def __call__(self, *args, **kwargs):
import pdb, sys
debugger = pdb.Pdb()
debugger.use_rawinput = 0
debugger.reset()
sys.settrace(debugger.trace_dispatch)
try:
return self.__object(*args, **kwargs)
finally:
debugger.quitting = 1
sys.settrace(None)
application = Debugger(application)