Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schedule every minute schedules every 61 seconds #355

Closed
microprediction opened this issue Mar 3, 2020 · 3 comments
Closed

schedule every minute schedules every 61 seconds #355

microprediction opened this issue Mar 3, 2020 · 3 comments

Comments

@microprediction
Copy link

Scheduling every minute leads to drift. The job is called at 36 seconds past the hour, then 37, then 38 and so forth.

@aekasitt
Copy link

Is this caused by your delay?
For example...

schedule.every().minute.do(job)
while True:
  try:
    schedule.run_pending() # 60 Seconds
    time.sleep(1)                   # 1 Second
  except KeyboardInterrupt:
    break

Perhaps use schedule.idle_seconds()

schedule.every().minute.do(job)
while True:
  try:
    schedule.run_pending()
    time.sleep(schedule.idle_seconds())
  except KeyboardInterrupt:
    break

@rajsid1
Copy link

rajsid1 commented Jul 29, 2020

This worked fine:

while True:
  schedule.run_pending()
  time.sleep(max((schedule.idle_seconds() - 1),0))

@Hantuch
Copy link

Hantuch commented May 17, 2022

Hello, the solution helped in reducing drifts, but it seems the scheduler didn't took the function run-time into consideration (my function was I/O bound, took 0.7-0.8 s) and still caused drifts

Am I correct about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants