Skip to content

Instantly share code, notes, and snippets.

@dragon0
Created December 1, 2017 22:03
Show Gist options
  • Save dragon0/18108dc44c2da641bd8d420ff634faa4 to your computer and use it in GitHub Desktop.
Save dragon0/18108dc44c2da641bd8d420ff634faa4 to your computer and use it in GitHub Desktop.
Debug a Python program on Ctrl-C
# 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