-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Support task backoff #81
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
Conversation
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (98.70%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #81 +/- ##
==========================================
+ Coverage 94.17% 94.42% +0.25%
==========================================
Files 74 74
Lines 2147 2208 +61
==========================================
+ Hits 2022 2085 +63
+ Misses 125 123 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general concern with this is that we could end up with a task infinitely failing and being rescheduled, right? Also, I don't see any logic here that 'nullifies' the original retry logic that will still retry the task as soon as possible, to a maximum of 3 times. Shouldn't we also intercept that logic somehow?
src/task_processor/processor.py
Outdated
| assert registered_task.task_handler, ( | ||
| "Attempt to back off a recurring task (currently not supported)" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use registered_task.task_type here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion also reassures Mypy that the task_handler attribute is not None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified/cleaned up in b289839.
This is a valid concern. We could do one of the following to address it:
Note that both of the options will cap the backoff attempts at the currently hard-coded value of 3 attempts.
Good catch, done in b905d54 — but that will need to be reverted should we choose the option (2) above. |
|
Implemented option 2 in 9de8df5, which also resulted in a leaner overall diff 👍 |
This PR adds support for task backoff via raising a
TaskBackoffError.The task runner now reschedules a task if the above exception class is raised inside a regular (non-recurring) task. The exception class supports a
delay_untilargument to specify which datetime the next task invocation should be scheduled for. If not specified,settings.TASK_BACKOFF_DEFAULT_DELAY_SECONDSwill be used.