Reputation: 405
I got a problem is: have a variable total time is t_total
after a time in t_total
i want to run some function and the time continue count up or down to the end of t_total
. It look like:
---t1---t2--
when time equal t1 run a function and in t2 run another function.
I tried to make a count function:
for t in range(t_total):
t = t + 1
time.sleep(1)
if t = t1:
function1()
but if follow that function the count up will stop at time when run function1. So, have anyway to keep the count continue to run the function2?
Upvotes: 0
Views: 110
Reputation: 20369
You can do using thread
import threading
for t in range(t_total):
t = t + 1
time.sleep(1)
if t = t1:
threading.Thread(target=function1).start()
Upvotes: 5
Reputation: 17
Add into function 1 to start a new timer starting at time t. You can export the value of t, t1 and t2 into function 1 and continue a new timer.
Upvotes: 0