Skip to content

Instantly share code, notes, and snippets.

@ipl31
Created July 7, 2021 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipl31/8f14a33f7a0241ee97c8856d14602052 to your computer and use it in GitHub Desktop.
Save ipl31/8f14a33f7a0241ee97c8856d14602052 to your computer and use it in GitHub Desktop.
testing atexit
""" Test script to debug atexit SIGTERM handling """
import atexit
import os
import signal
import sys
import time
@atexit.register
def cleanup():
print("atexit handler called")
def killme(pid):
os.kill(pid, signal.SIGTERM)
if __name__ == "__main__":
pid = os.getpid()
if sys.argv[1] == 'wait':
print(f"Sleeping for 60 seconds, go run kill {pid} from cli")
time.sleep(60)
if sys.argv[1] == 'kill':
killme(pid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment