Debugging

Entering A Running Python Process

pyrasite-shell is a great tool for attaching to a running Python process. You can install it using pip with:

You can then attach a pyrasite shell to a running python process using the process ID (PID):

You should then be presented with an interactive Python shell, and you can do things like print the stack trace for each thread:

Note that annoyingly, coping and pasting this code into the interactive console will not usually work (due to whitespace getting mangled perhaps?).

pyrasite-shell is a great tool for attaching to “hung” or “frozen” Python processes, which might be stuck in a loop or stuck in a blocked state waiting for something to happen.

Posted: June 27th, 2018 at 8:37 am
Last Updated on: July 18th, 2018 at 4:55 am