django-background-tasks icon indicating copy to clipboard operation
django-background-tasks copied to clipboard

best way to start repeating tasks and question about failing

Open hansioan opened this issue 3 years ago • 0 comments

I have a task that I wish to run , say, every week to do some analysis, and some updates to some parts of the DB.

I know I can use repeating tasks to run things, combined with manage process_tasks but what is the best way to initialise a repeating task? Should I just start process_tasks to listen and then call once the "repeating task" so that it gets added to the background_task table?

Regarding failing tasks in the docs for repeating tasks it says:

On the other hand, if a repeating task fails and is not restarted, the repetition chain is stopped.

https://django-background-tasks.readthedocs.io/en/latest/#repeating-tasks

but in the docs in the Task Errors section https://django-background-tasks.readthedocs.io/en/latest/#task-errors it says:

Tasks are retried if they fail and the error recorded in last_error (and logged).

If a repeating task fails, is it retried or not?

I currently use django-background-tasks only to run some code that should not run immediately so that it doesn't delay the response (e.g. send an email after new user signup)

If failing repeating tasks don't get retried then I guess I could just use cron and call a manage my_own_task every week from cron.

Any advice for the above? I am aware of Celery, but I am trying to avoid the complexity unless I'm really forced to use it.

Thanks

hansioan avatar Sep 09 '21 10:09 hansioan