Skip to content

Instantly share code, notes, and snippets.

View soxofaan's full-sized avatar

Stefaan Lippens soxofaan

View GitHub Profile
@soxofaan
soxofaan / pyrasite-stacktrace-how-to.md
Last active March 22, 2024 00:45 — forked from reywood/how-to.md
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.