Skip to content

Instantly share code, notes, and snippets.


Stefaan Lippens soxofaan

View GitHub Profile
soxofaan /
Last active Feb 9, 2021 — forked from reywood/
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running Python script

Sometimes a Python script will simply hang forever with no indication of what is going wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward.

Here's a way to see where the program is currently stuck, using pyrasite a tool for injecting code into running Python processes.

Install gdb and pyrasite

Install gdb.