17π
β
The task needs to accept keyword arguments, they are used to pass information amongst other about the retry count. I think the code should look like this:
from celery.decorators import task
@task()
def add(x, y, **kwargs):
if not x or not y:
try:
raise Exception("test error")
except Exception, e:
add.retry(args=[x, y], exc=e, countdown=30, kwargs=kwargs)
return x+y
**kwargs
need to be added to the signature of the add
function, and passed as kwargs=kwargs
when calling retry.
Note: this style was deprecated with the release of celery 2.2.
π€Reiner Gerecke
28π
You can set your retry parameters in the decorator:
@task(default_retry_delay=5 * 60, max_retries=12)
def foo(bar):
try:
...
except Exception, exc:
raise foo.retry(exc=exc)
π€dalore
- [Django]-ImportError: No module named crispy-forms
- [Django]-Django unit testing for form edit
- [Django]-HTML input file β how to translate "Choose File" and "No file Chosen"?
Source:stackexchange.com