You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import schedule
import time
def job(t):
print "I'm working...", t
return
schedule.every().day.at("10:00").do(job,'It is 01:00')
while True:
schedule.run_pending()
time.sleep(60) # wait one minute
But the computer was hibernating until 11:00? will the task still be scheduled? what about 23 hours later?
The text was updated successfully, but these errors were encountered:
In the example you provided, the job is scheduled to run every day at 10:00. If the computer is hibernating until 11:00, the scheduled task will be run whenever the computer wakes up and the run_pending() function is called.
Every job has an next_run variable with a datetime that indicates when the next job should run. This can be seen when you print the job:
print(repr(schedule.every().day.at("10:00").do(job,'It is 01:00')))
# Every 1 day at 10:00:00 do job('It is 01:00') (last run: [never], next run: 2023-04-11 10:00:00)
The run_pending simply looks at all the jobs' next_run, and whenever the current time is equal or after the next_run, it will run the job and calculate the new next_run. So when the program execution was paused (run_pending was not called for a long time), then whenever the next time run_pending runs, all missed jobs are ran.
For example the code:
But the computer was hibernating until 11:00? will the task still be scheduled? what about 23 hours later?
The text was updated successfully, but these errors were encountered: