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

[MacOs] Cannot schedule job to run after x minutes if machine sleeps. #318

Open
akshaypawar123 opened this issue Mar 11, 2022 · 2 comments

Comments

@akshaypawar123
Copy link

Hello All,
I am trying to schedule a job to run once after x minutes, but want to make sure the time passed when machine sleeps is not counted.
I am not seeing expected behavior in below scenario:

  1. Schedule a job to run once after 5 minutes.
  2. Wait for 1 minute. Put machine to sleep and wake it up after 30 minutes.

Expected behavior : Scheduled job is triggered 4 minutes (1 minute has already passed) after wakeup.
Actual behavior : Scheduled job is triggered immediately after machine wakesup.

Are there any properties that need to be set to make this work? Thanks!

@mrgfisher
Copy link

mrgfisher commented Mar 12, 2022

Whilst I'm not the author, I do use this library in a personal project and very much like it...

@akshaypawar123 - I wouldn't expect the behavior you are expecting :-)

If at 12:00 my app starts up and then schedules a job for 5 minutes time, I would definiately expect it to run at the clock time of 12:05 or as soon as possible subject to external factors (other jobs taking CPU cycles or indeed the host being suspended).

I can't think of a sensible way for the scheduler to measure 'potential run time because the host is awake' to accurately run the job after 5 minutes of awake time vs clock time. That said, one super crude hack would be to have the job run (say) every minute, keep some internal state, and then when the counter gets to 5 to actually run the logic. Of course, the best solution might be to not put the host to sleep if its meant to be doing scheduled jobs... 😊

@akshaypawar123
Copy link
Author

akshaypawar123 commented Mar 12, 2022 via email

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

2 participants