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

Cron scheduled tasks cleanup on TaskiqScheduler start #297

Open
sector119 opened this issue Feb 22, 2024 · 1 comment
Open

Cron scheduled tasks cleanup on TaskiqScheduler start #297

sector119 opened this issue Feb 22, 2024 · 1 comment

Comments

@sector119
Copy link

Hello,

After scheduler restart all cron scheduled tasks are getting duplicated...
Should we remove all scheduled tasks on scheduler startup like in code bellow? Right now only time (not cron) scheduled tasks are removed on "post_send", but if scheduler was killed or stopped before task was delivered to the worker it wouldn't be deleted too

Right now I cleanup scheduled tasks at TaskiqScheduler method

async def startup(self) -> None:
for source in self.sources:
tasks = await source.get_schedules()

    for task in tasks:
        await source.delete_schedule(task.schedule_id)
@s3rius
Copy link
Member

s3rius commented Apr 19, 2024

So, you can use labeleschedulesource for static crons. It doesn't store anything anywhere. It reads all available tasks and creates schedules based on tasks labels. You can add it along redis-schedule-source to enable this functionality.

But if you want to add them dynamically and use other schedule_sources, then that's the only way.

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

No branches or pull requests

2 participants