Miksus / rocketry

Modern scheduling library for Python
https://rocketry.readthedocs.io
MIT License
3.28k stars 108 forks source link

BUG: Hourly tasks are being run on server restarts #217

Closed themousepotato closed 1 year ago

themousepotato commented 1 year ago

Describe the bug

I want to only execute tasks once in every hour during the start of the hour but, every periodic task is being executed at server restart as well. Is there a way to disable this behaviour?

To Reproduce Restart the server and watch periodic tasks

Expected behavior Periodic hourly task should only get executed at the start of the hour and not during server restarts

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

themousepotato commented 1 year ago

Found the fix:

def run_scheduler(rocketry_app: Rocketry):
    for task in rocketry_app.session.tasks:
        # log a non-action to stop bug where hourly, daily, weekly, monthly tasks are run immediately
        task.log_inaction()

    rocketry_app.run()