Created
May 13, 2016 19:17
-
-
Save takluyver/8c25dcf1f175159b0c741207a6dda94a to your computer and use it in GitHub Desktop.
Debug on interrupt
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
$ 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) |
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
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