Created
March 28, 2018 06:47
-
-
Save cwen0/f4b74f9d356cc40a86cdc267b60067cd to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python2.7 | |
from threading import Event | |
exit = Event() | |
def main(): | |
while not exit.is_set(): | |
do_my_thing() | |
exit.wait(60) | |
print("All done!") | |
# perform any cleanup here | |
def quit(signo, _frame): | |
print("Interrupted by %d, shutting down" % signo) | |
exit.set() | |
if __name__ == '__main__': | |
import signal | |
for sig in ('TERM', 'HUP', 'INT'): | |
signal.signal(getattr(signal, 'SIG'+sig), quit); | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment