Standard tzinfo is not enough for apscheduler
See original GitHub issueExpected Behavior
apscheduler
should work with next_run_time
specified with standard tzinfo
.
Current Behavior
apscheduler
crashes.
Steps to Reproduce
from datetime import datetime, timedelta
from dateutil.tz import tzutc
next_run_time = datetime.now(tzutc()) + timedelta(seconds=30)
scheduler.add_job(
lambda: print("Hello"), trigger=IntervalTrigger(minutes=1), next_run_time=next_run_time
)
Context (Environment)
apscheduler
works only with pytz
objects, the problematic call is there : https://github.com/agronholm/apscheduler/blob/18b50d9ee9ff14e816b557e34d7d3abc861d57e5/apscheduler/triggers/interval.py#L66
If next_fire_time
is not stamped with a pytz.tzinfo.BaseTzInfo
, it crashes.
self.timezone
is a pytz
object, normalize()
is a pytz
function which expects a pytz.tzinfo.BaseTzInfo
as argument (see https://github.com/stub42/pytz/blob/master/src/pytz/tzinfo.py#L66) with an internal (and absent from the standard tzinfo
) _utcoffset
there : https://github.com/stub42/pytz/blob/master/src/pytz/tzinfo.py#L252.
Issue Analytics
- State:
- Created 4 years ago
- Comments:25 (13 by maintainers)
Top Results From Across the Web
APScheduler Documentation - Read the Docs
You can schedule jobs on the scheduler at any time. If the scheduler is not yet running when the job is added, the...
Read more >'Only timezones from the pytz library are supported' error
The tzlocal library switched from pytz to zoneinfo timezones in 3.0 and APScheduler 3.x is not compatible with those.
Read more >apscheduler/Lobby - Gitter
Hi, I have got a Django application implementing a notification system (that involves me to schedule them based on some logic) using AP-Scheduler....
Read more >apscheduler - Bountysource
Standard tzinfo is not enough for apscheduler $ 0 ... Created 3 years ago in agronholm/apscheduler with 22 comments. Expected Behavior. apscheduler should...
Read more >Incorrect Run Date Timezone For Apscheduler - ADocLib
Read about Apscheduler Date Timezone collectionbut see also Apscheduler Timezone also Standard tzinfo is not enough for apscheduler Issue #384.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
v4.0.0a1 accepts a wider range of tzinfo objects. If you still have trouble, open a new issue against v4.0.0a1.
It already does, in
master
.