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

前端 未结 9 2196
日久生厌
日久生厌 2020-12-13 18:49

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?

9条回答
  •  半阙折子戏
    2020-12-13 19:27

    Yeah, gdb is good for lower level debugging.

    You can change threads with the thread command.

    e.g

    (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.

提交回复
热议问题