Skip to content

Instantly share code, notes, and snippets.

@alecbw
Created May 26, 2021 15:32
Show Gist options
  • Save alecbw/d536c7b892f800491c162df257d68e5c to your computer and use it in GitHub Desktop.
Save alecbw/d536c7b892f800491c162df257d68e5c to your computer and use it in GitHub Desktop.
Logs SIGKILL value such that an Error Handling platform like Sentry can capture it
import signal
def shutdown(signum, frame):
logging.error(f'Caught SIGTERM {signum}, shutting down')
exit(0)
if __name__ == "__main__":
# Register handler
signal.signal(signal.SIGTERM, shutdown)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment