-
-
Save seba-1511/76809de7cd1f294b96958559e51242bf to your computer and use it in GitHub Desktop.
Debug on interrupt
This file contains hidden or 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 hidden or 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