dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.77k stars 961 forks source link

instant execution of job with every().days.at on first run #603

Open alkanex-xyz opened 11 months ago

alkanex-xyz commented 11 months ago

When I schedule a job with schedule.every().days.at("00:00:20", timezone("Europe/Amsterdam")).do() the job will run immediately even if the first call of run_pending is at 15:00.

How can i prevent the instant execution? The first execution shall be at the next day

Python3.11 Schedule 1.2.1

alkanex-xyz commented 11 months ago

maybe some additional infos:

On my windows 11 PC this doesn't seems to happen. On the script running in kubernetes containers on mediawikis toolforge servers it seems to occure only on jobs which are scheduled in hour 0 and 1.

The servers time is set to UTC.

alkanex-xyz commented 11 months ago

Further tests:

When I set my timezone to UTC the same thing occurs. If the job is scheduled between 00:00 and 01:59 (MEST) the task will run immediately and additional: the task is immediately rescheduled after each run. I would guess till the 2 hours offset between UTC and MEST have passed

SijmenHuizenga commented 11 months ago

Thank you the detailed explanation and investigation. This is indeed a bug. I've started working on a fix in #604

SijmenHuizenga commented 11 months ago

Hi @alkanex-xyz, the fix in #604 seems to work good with the test cases I can come up with. Would you be willing to also take a look at it? Either by reviewing, running it as part of your program or by writing a unit-test like the these ones that represents your situation? Any testing/reviewing help would be super helpful to move this forward.

alkanex-xyz commented 11 months ago

Hey, I've tested my case and the schedule run as intended. Thanks a lot .

wasnertobias commented 10 months ago

609 Sorry I did create a duplicate, did not find this issue before as I thought it was Docker related. The issue is still persisting for me.