CronTrigger runs into infinite loop at daylight savings time boundary

Author: suolaCreated Jan 24, 2025Updated Sep 19, 2026
Labelsbug

Things to check first

  • I have checked that my issue does not already have a solution in the FAQ

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Version

3.11.0

What happened?

Similar bug as https://github.com/agronholm/apscheduler/issues/980 which was fixed on master, this is on v3.11. I commented this in that issue, but am now creating a separate issue since that issue was closed.

How can we reproduce the bug?

from zoneinfo import ZoneInfo
from datetime import datetime

from apscheduler.triggers.cron import CronTrigger

tz = ZoneInfo("Europe/Helsinki")
trigger = CronTrigger(minute=30, timezone=tz)
dt = datetime(2017, 10, 29, 3, 45, tzinfo=tz, fold=1)

dt = trigger.get_next_fire_time(dt, dt)
# dt = datetime.datetime(2017, 10, 29, 3, 30, fold=1, tzinfo=zoneinfo.ZoneInfo(key='Europe/Helsinki'))

dt = trigger.get_next_fire_time(dt, dt)
# dt = datetime.datetime(2017, 10, 29, 3, 30, fold=1, tzinfo=zoneinfo.ZoneInfo(key='Europe/Helsinki'))