Interrupt (pause) running Python program in pdb?

余生颓废 提交于 2019-11-29 03:03:19

Based on this bug report it might be fixed in Python 3.

In 2.x Ctrl-C will throw a KeyboardInterrupt, which is typically unhandled by the program, and will put the debugger into 'post-mortem' mode. You cannot continue where you left off.

I don't know if there's some other way to do what you are describing.

JDiMatteo

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:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!