Created
July 7, 2021 15:45
-
-
Save ipl31/8f14a33f7a0241ee97c8856d14602052 to your computer and use it in GitHub Desktop.
testing atexit
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
""" 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