taskiq icon indicating copy to clipboard operation
taskiq copied to clipboard

Cron scheduled tasks cleanup on TaskiqScheduler start

Open sector119 opened this issue 1 year ago • 1 comments
trafficstars

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)

sector119 avatar Feb 22 '24 13:02 sector119

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.

s3rius avatar Apr 19 '24 23:04 s3rius