Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-memory data store does not handle timezone correctly #975

Closed
3 tasks done
ochachacha opened this issue Oct 15, 2024 · 2 comments
Closed
3 tasks done

In-memory data store does not handle timezone correctly #975

ochachacha opened this issue Oct 15, 2024 · 2 comments
Labels

Comments

@ochachacha
Copy link

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

4.0.0a5

What happened?

This issue was reported in #807 for SQLAlchemyDataStore and also mentioend here, but seems not fixed yet for in-memory data store. When a paused schedule created with timezone reaches its trigger time, the next fire time is not correctly updated, resulting in infinite rapid retrying of the scheduler.

How can we reproduce the bug?

The following code demonstrates the problem:

import sys
from zoneinfo import ZoneInfo
from apscheduler import Scheduler
from apscheduler.triggers.cron import CronTrigger
import logging

def hello_world():
    logging.root.info("hello")

logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
logging.root.setLevel(logging.DEBUG)
scheduler = Scheduler(logger=logging.root)
cron_trigger = CronTrigger(second = "*", timezone = ZoneInfo("America/New_York"))
schedule_id = scheduler.add_schedule(hello_world, cron_trigger)
scheduler.start_in_background()
scheduler.pause_schedule(schedule_id)

Then, upon running this code, the following output can be observed:

Using selector: KqueueSelector
Added new schedule (task='__main__:hello_world', trigger=CronTrigger(year='*', month='*', day='*', week='*', day_of_week='*', hour='*', minute='*', second='*', start_time='2024-10-15T16:25:22.965474-04:00', timezone='America/New_York')); next run time at 2024-10-15 16:25:23-04:00
Scheduler started
Sleeping 0.028 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.001 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.001 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.001 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.001 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.001 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.001 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.002 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.002 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.002 seconds until the next fire time (2024-10-15 16:25:23-04:00)
Sleeping -0.002 seconds until the next fire time (2024-10-15 16:25:23-04:00)
...
@ochachacha ochachacha added the bug label Oct 15, 2024
@agronholm
Copy link
Owner

I can't reproduce this on master. Can you?

@ochachacha
Copy link
Author

I can't reproduce this on master. Can you?

Agreed, on master this does not seem to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants