Reputation: 13
using python i have the user enter a preset time. in hours and minutes. and once it is that time, it triggers a function. so i have a loop where every second it checks and if it isnt that time, it check again in once second. but if it is that time i want it to go to that time.
this is the code:
while (hour() != schedhr) and (minute() != schedmin):
time.sleep(1)
if (schedhr == hour()) and (schedmin == minute()):
#do function
but what happens is, it will wait till the time and then exit as if the script ended instead of doing the function
Upvotes: 0
Views: 153
Reputation: 201447
If I understand you, you might use time.sleep(seconds)
from time import sleep
while (hour() != schedhr) and (minute() != schedmin):
time.sleep(1)
doFunc() # <-- the timer has ended.
Upvotes: 1