Skip to content

Instantly share code, notes, and snippets.

@klingtnet
Created May 9, 2017 10:54
Show Gist options
  • Save klingtnet/6ad92343505dfc4edc283ffa2f962f1a to your computer and use it in GitHub Desktop.
Save klingtnet/6ad92343505dfc4edc283ffa2f962f1a to your computer and use it in GitHub Desktop.
Python signal handling
#!/usr/bin/env python3
import signal
import sys
import time
def handler(signr, stackframe):
print("Killed with {}".format(signr))
sys.exit(1)
signal.signal(signal.SIGUSR1, handler)
print("Sleeping for 1000 seconds...")
time.sleep(1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment