I would like to use Timer
to exit a script where an infinite loop is running.
Here is a simple stub that I created to test that logic:
import threading
import sys
import time
def exit():
sys.exit()
if __name__ == '__main__':
t = threading.Timer(3, exit)
t.start()
while True:
time.sleep(3)
This doesn't make the script to sys.exit
though.
Any pointer why, and how can i achieve the Timer
to sys.exit
the main thread?