Skip to content

Instantly share code, notes, and snippets.

@mudream4869
Created February 10, 2022 15:23
Show Gist options
  • Save mudream4869/bc2accadaa79d17565c99b7c67adfe42 to your computer and use it in GitHub Desktop.
Save mudream4869/bc2accadaa79d17565c99b7c67adfe42 to your computer and use it in GitHub Desktop.
interrupted sleep
import signal, time
class InterruptSleep(Exception):
pass
def main():
while True:
try:
time.sleep(60)
except InterruptSleep:
return
def quit(signo, frame):
raise InterruptSleep()
if __name__ == '__main__':
signal.signal(signal.SIGTERM, quit)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment