I have a python script that I suspect that there is a deadlock. I was trying to debug with pdb but if I go step by step it doesn\'t get the deadlock, and by the
Use pyrasite:
>>> pyrasite 172483 dump_stacks.py
...where 172483 is the PID of the running python process. The python process will then print a stack trace for each thread. One can send arbitrary Python code to be executed or open a shell.
This is great for debugging dead locks. One can even install pyrasite after the hanging process has been started. But be aware that you should install it in the same environment to make it work.
This is not the only tool available, but for some reason it seems to be really hard to stumble over it accidentally. It is old, but works like a charm for Python 2 and 3.