Open komodovaran opened 6 months ago
APScheduler 3.x requires pytz timezones. I'm surprised there was no warning or error. Have you tried with pytz yet? APScheduler 4.x (currently in alpha) uses ZoneInfo
but it's not recommended for production yet.
Interestingly enough I get the exact same behavior and outcome if I use pytz.timezone
instead of ZoneInfo
.
Seems like CronTrigger.timezone
actually defaults to the local timezone:
https://github.com/agronholm/apscheduler/blob/2a2210fc71683547f8b01c7d4552815c3b67c1fe/apscheduler/triggers/cron/__init__.py#L49-L59
Even though the below docstrings suggest otherwise: https://github.com/agronholm/apscheduler/blob/2a2210fc71683547f8b01c7d4552815c3b67c1fe/apscheduler/triggers/cron/__init__.py#L28-L29 https://github.com/agronholm/apscheduler/blob/2a2210fc71683547f8b01c7d4552815c3b67c1fe/apscheduler/triggers/cron/__init__.py#L94-L95
In 4.0
, the docstrings correctly say that CronTrigger.timezone
defaults to the local timezone:
https://github.com/agronholm/apscheduler/blob/c921db43dad8ad8f6cfdcc8539bfad0980b1529c/src/apscheduler/triggers/cron/__init__.py#L41-L42
https://github.com/agronholm/apscheduler/blob/c921db43dad8ad8f6cfdcc8539bfad0980b1529c/src/apscheduler/triggers/cron/__init__.py#L123-L124
Things to check first
[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Version
3.10.4
What happened?
Scenario: I want a job to run at 12 AM locally, in a given timezone. For Singapore, which I've arbitrarily chosen because of the big difference, this is equal to 4 AM UTC.
So I read that the scheduler takes a timezone and set it up like
This yields
So there doesn't seem to be any indication that this is going to run in some other timezone.
But if I specify the timezone in the
CronTrigger
(regardless of whether the scheduler has the argument or not) it yieldsSo now it looks like it's going to fire tomorrow at 4 AM, like I expect it to.
So it seems like the timezone has no effect on the scheduler. Or do I misunderstand?
How can we reproduce the bug?
See minimal example above. Requires a local MySQL instance, or similar.