Created
October 12, 2022 14:25
-
-
Save sfengyuan/b71425f157e957a933aadb0e53cab66c to your computer and use it in GitHub Desktop.
Catch KeyboardInterrupt
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 sys | |
user_stop = False | |
def signal_handler(sig, frm): | |
global user_stop | |
user_stop = True | |
signal.signal(signal.SIGINT, signal_handler) | |
# signal.pause() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment