I need to set multi-timers in the same script, i have two functions fun_1()
and fun_2()
that I want to execute one time by minute.
I want to execute the two timers in the same time and be able to kill them with keyboardinterrupt
.
What I tried so far is:
import threading
def timer_1():
fun_1()
threading.Timer(60.0, timer_1).start()
def timer_2():
fun_2()
threading.Timer(60.0, timer_2).start()
if __name__ == "__main__":
timer_1()
timer_2()
There is two problems with my code:
timer_2
will be executed after one minute of thetimer_1
execution- The
keyboardInterrupt
is ignored