Created
December 1, 2017 22:03
-
-
Save dragon0/18108dc44c2da641bd8d420ff634faa4 to your computer and use it in GitHub Desktop.
Debug a Python program on Ctrl-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Signal handler example. Debugger starts with Ctrl-C: | |
import signal | |
def int_handler(signal, frame): | |
import pdb | |
pdb.set_trace(frame) | |
signal.signal(signal.SIGINT, int_handler) | |
# Put that at the top of your script and you can start debugging your script at any | |
# point by type Ctrl-C. Resume programe execution by typing exit at the Pdb prompt. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment