cowbird.request_task
Exceptions
Exception raised when the chain must be interrupted. |
Classes
Celery base task that should be used to handle API requests. |
Module Contents
- exception cowbird.request_task.AbortException[source]
Bases:
Exception
Exception raised when the chain must be interrupted.
Initialize self. See help(type(self)) for accurate signature.
- class cowbird.request_task.RequestTask[source]
Bases:
celery.app.task.Task
,abc.ABC
Celery base task that should be used to handle API requests.
- Using this class will set the following Task configuration :
auto-retry for every RequestException
backoff and jitter strategy
There is also an abort_chain function to stop the chain of requests in case of an unrecoverable event
To use this class simply decorate your asynchronous function like this:
from celery import shared_task @shared_task(bind=True, base=RequestTask) def function_name(self, any, wanted, parameters): pass # function operations
Parameter
bind=True
will provide the self argument to the function which is the celery Task (not required).Parameter
base=RequestTask
will instantiate a RequestTask rather than a base celery Task as the self object.- autoretry_for: Tuple[Exception][source]
Exceptions that are accepted as valid raising cases to attempt request retry.
- retry_backoff = True[source]
Enable backoff strategy during request retry upon known raised exception.
- retry_backoff_max = 600[source]
Maximum backoff delay permitted using request retry.
Retries are abandoned if this delay is reached.