RealOrangeOne / django-tasks

A reference implementation and backport of background workers and tasks in Django
https://pypi.org/project/django-tasks/
BSD 3-Clause "New" or "Revised" License
211 stars 13 forks source link

Enhancement request: repeating tasks #22

Closed jribbens closed 4 weeks ago

jribbens commented 1 month ago

There really needs to be a way of saying "call this task regularly", both of the simple "every 15 minutes" type and the more-complex "weekdays at 9am" type.

You might say this isn't necessary in a version 1.0 implementation, but that would be to forget the mistake of JavaScript 1.0 having setTimeout but no setInterval and all sorts of havoc ensuing until they added the latter in version 1.2 (and the havoc continuing to exist for many years as people needed to remain compatible with 1.0). Better to learn from history than repeat it :-) If you don't support this from the beginning then it's just going to force multiple incompatible third-party libraries to spring into existence to fill the gap and you'll be perpetuating the very problem your new system is designed to solve.

Apologies for suggesting adding complexities to your nice neat specification...

mast3rbow commented 4 weeks ago

A schedule table would let you create list of tasks and potentially cascading tasks, where a event could trigger a new schedule, that schedule could run every hour for example. You could then create business logic to add/remove schedules would which give you flexibility.

Then we would just need a task that might check the table every "x amount of time" and queue up tasks.

You would need to enable time zone support and potentially start with simple intervals like second, min, hour, day, week, month etc.

RealOrangeOne commented 4 weeks ago

I think this is the same as cron-based scheduling, so I'm going to close this in favour of moving the discussion there: https://github.com/RealOrangeOne/django-tasks/discussions/8