Created
February 10, 2022 15:23
-
-
Save mudream4869/bc2accadaa79d17565c99b7c67adfe42 to your computer and use it in GitHub Desktop.
interrupted sleep
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
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