Created
August 30, 2013 12:54
-
-
Save mikerr/6389549 to your computer and use it in GitHub Desktop.
Python: Capture CTRL+C / SIGINT and exit gracefully
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 | |
def handler(signum, frame): | |
print 'Got CTRL+C' | |
exit (0) | |
signal.signal(signal.SIGINT, handler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment