django-background-tasks
django-background-tasks copied to clipboard
Disable Retry when error. Already tried with MAX_ATTEMPT = 1 . MAX_ATTEMPTS = 0
That actual post is closed so asking it again. MAX_ATTEMPTS is not working when set to 1. it is running twice. first, it runs, and then it retries 1 more time. I have checked with changing it to other values. I want to run it only once. doesn't matter it passes or fails. So I tried MAX_ATTEMPTS as 0. even though it didn't work.
Do I need to set MAX_RUN_TIME also because my script run time would take more than 24 HRS? I see its default is 3600.
My requirement is to run a script don't try it if it fails and script run time can be between few seconds to few days.
Please help
I am having the same issue in my project. I have been using this library for over a year now and know it pretty well. It does not seem to honor the MAX_ATTEMPTS, or at least not in the way we expect.
If the Task is still locked it seems to consider the task in progress and will consider the retry the first attempt. If a task is hung or taking longer than the MAX_RUN_TIME it will execute the whole task again when the desired behavior would be for it to allow the last task to run and not retry.
One of the primary benefits of a library like this is to get away from the runaway cronjob type execution where a task can outrun the next iteration and stack up processes. This issue reproduces that cron like behavior in this library.
@jason-burbach how u solved the issue? i just needed it to start a task after some time which is 5 seconds after submitting the task and it was doing so. After that i used threading to call my other method in daemon False and its working fine now. Other tasks can come. And also i have increased the lock time to 5days.
This is probably not the answer you are looking for, but I solved it by removing BG Tasks completely from this part of my application. I use it for cyclic tasks that need to run on a cycle and unlock if a sub-thread unexpectedly terminates.
However, for single tasks that can be long running and take time to complete, I now manage the thread directly.
can this be used for periodic tasks also? and ETA to run the task once. like scheduling. For scheduling, I am using celery and seeing that celery is submitting the same tasks multiple times. like some times 10 times.
I have also used threading. now task is executed after few seconds and from there it starts a new thread which is working for me now.