Skip to content

Instantly share code, notes, and snippets.

@sfengyuan
Created October 12, 2022 14:25
Show Gist options
  • Save sfengyuan/b71425f157e957a933aadb0e53cab66c to your computer and use it in GitHub Desktop.
Save sfengyuan/b71425f157e957a933aadb0e53cab66c to your computer and use it in GitHub Desktop.
Catch KeyboardInterrupt
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