Readonly Readonly - 1 month ago 5
Python Question

Is there a way to attach a debugger to a multi-threaded Python process?

I'm trying to debug a deadlock in a multi-threaded Python application after it has locked up. Is there a way to attach a debugger to inspect the state of the process?

Edit: I'm attempting this on Linux, but it would be great if there were a cross-platform solution. It's Python after all :)


Yeah, gdb is good for lower level debugging.

You can change threads with the thread command.


(gdb) thr 2
[Switching to thread 2 (process 6159 thread 0x3f1b)]
(gdb) backtrace

You could also check out Python specific debuggers like Winpdb, or pydb. Both platform independent.