Interrupt (pause) running Python program in pdb?

后端 未结 2 1620
旧巷少年郎
旧巷少年郎 2020-12-16 10:45

In gdb, you can interrupt(pause) the program by C-c and resume.

Can you do this in pdb?

2条回答
  •  醉话见心
    2020-12-16 11:35

    No, python2's pdb doesn't support this, but you add this code to your program as a workaround:

    def debug_signal_handler(signal, frame):
        import pdb
        pdb.set_trace()
    import signal
    signal.signal(signal.SIGINT, debug_signal_handler)
    

    Related questions:

    • Showing the stack trace from a running Python application
    • enter pdb with kill signal

提交回复
热议问题