Closed AnezeR closed 1 year ago
I think the issue is in this block
https://github.com/dbader/schedule/blob/a3c2074dcd8f39168525f0fc2b009bc7119f0796/schedule/__init__.py#L752-L771
It subtracts one day if self.at_time is greater than now():
https://github.com/dbader/schedule/blob/a3c2074dcd8f39168525f0fc2b009bc7119f0796/schedule/__init__.py#L768
But, since self.at_time
is not updated in
https://github.com/dbader/schedule/blob/a3c2074dcd8f39168525f0fc2b009bc7119f0796/schedule/__init__.py#L752-L759
It still executes.
E.G.
If the machine uses UTC time and execution time is 20:00 in UTC+3, self.next_run would change to 17:00 UTC, while self.at_time would stay at 20:00.
Now, if the machine time is 19:00 UTC, it should not subtract a day, since it is already 2 hours past execution time, but, it would see, that 19:00 is less than 20:00 and subtract a day from self.next_run
Thank you so much for investigating and creating a pr! #583 has been merged and released in 1.2.1
local python version: 3.9.16 docker python: python:3.9-slim-buster
schedule==1.2.0 pytz==2023.3
I have this code, which I run inside a docker container
In this case it outputs negative time and would attempt to run
send_practice_notifications
, which I want to happen only at specified time, and not every time the program starts.When run natively, however, it outputs a positive expected value and does not run any functions.
30777.206617
I think this is an error related to time-zones because docker container uses UTC time, and running natively puts it in the Europe/Moscow timezone. Sure enough, changing the code in docker toMakes the output positive and expected
1709.825228