Skip to content

Instantly share code, notes, and snippets.

@seba-1511
Forked from takluyver/example
Created September 15, 2017 19:02
Show Gist options
  • Select an option

  • Save seba-1511/76809de7cd1f294b96958559e51242bf to your computer and use it in GitHub Desktop.

Select an option

Save seba-1511/76809de7cd1f294b96958559e51242bf to your computer and use it in GitHub Desktop.
Debug on interrupt
$ python3 interrupt-debug.py
0
1
2
3
^C--Return--
> /home/takluyver/scratch/interrupt-debug.py(6)handle_sigint()->None
-> pdb.set_trace()
(Pdb) p a
4
(Pdb)
import signal
import time
import pdb
def handle_sigint(signo, frame):
pdb.set_trace()
signal.signal(signal.SIGINT, handle_sigint)
for a in range(10000):
time.sleep(0.5)
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment