question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Standard tzinfo is not enough for apscheduler

See original GitHub issue

Expected 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:closed
  • Created 4 years ago
  • Comments:25 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
agronholmcommented, Aug 17, 2022

v4.0.0a1 accepts a wider range of tzinfo objects. If you still have trouble, open a new issue against v4.0.0a1.

1reaction
agronholmcommented, Jan 1, 2022

It already does, in master.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found