ClassBasedAutoRetryTask
This class provides a task implementation that automatically retries execution when a ValueError is encountered. It leverages built-in retry configurations, including a maximum retry limit and exponential backoff, to manage task persistence. The class tracks the number of retry attempts through the request state and returns the retry count upon successful completion.
Attributes
| Attribute | Type | Description |
|---|---|---|
| name | string = auto_retry_class_task | The unique identifier used to register the task within the Celery task registry. |
| autoretry_for | tuple = (ValueError,) | A tuple of exception classes that will trigger an automatic retry of the task when raised during execution. |
| retry_kwargs | dict = {'max_retries': 1} | A dictionary of configuration parameters, such as max_retries, passed to the retry method when an automatic retry is triggered. |
| retry_backoff | boolean = true | A boolean flag or numeric value that determines if an exponential backoff delay should be applied between task retries. |
Constructor
Signature
def ClassBasedAutoRetryTask() - > null
Methods
run()
@classmethod
def run() - > int
Executes the task logic, returning the current retry count if the task has been retried, or raising a ValueError to trigger the automatic retry mechanism.
Returns
| Type | Description |
|---|---|
int | The number of times the task has been retried according to the current request state. |