Skip to content

Instantly share code, notes, and snippets.

@dkeightley
Created May 31, 2019 14:41
Show Gist options
  • Save dkeightley/81ea27d1518183dd90ff985dc3c7e55f to your computer and use it in GitHub Desktop.
Save dkeightley/81ea27d1518183dd90ff985dc3c7e55f to your computer and use it in GitHub Desktop.
Example signal handling in Python
import signal
import sys
def exit_gracefully(signumber, frame):
print("Received signal", signumber, "cleaning up...")
sys.exit(0)
signal.signal(signal.SIGTERM, exit_gracefully)
## Do stuff here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment