Pyrasite: Tools for injecting code into running Python processes
pyrasite.com
pyrasite.com
Very useful.
By the way is worth noticing that you won't probably be able to attach the interactive console to a running web server as the output is usually handled by the supervisor process, at least I wasn't able to do that in my first tentative and the memory dump was good enough for me.
Check this sample to dump the memory out of a running process: http://pyrasite.readthedocs.org/en/latest/Payloads.html#dump...
It's one of those tools that you'll be glad exists when the need arises, but you'll feel a little dirty using it.
pdb is quite limited in what it can debug if you have a stuck process which is very hard to reproduce. I've resorted to gdb + python extensions too many times to count (which basically allows you do what pyrasite does, though at a lower level).
[1] http://aosabook.org/en/gdb.html [2] https://docs.python.org/2/c-api/veryhigh.html
This is why I wrote https://pypi.python.org/pypi/manhole - I couldn't afford hosing up (deadlocking) my processes, and it happen pretty often with pyrasite in my usecases. Have in mind that manhole is not that flexible as it uses different technique.