uptick / django-cq

Distributed tasks for Django Channels.
BSD 3-Clause "New" or "Revised" License
46 stars 6 forks source link

Automatic task retry? #3

Open ryanmcgrath opened 7 years ago

ryanmcgrath commented 7 years ago

Is there any mechanism or such for automatic task retrying? For some reason I thought there was.

furious-luke commented 7 years ago

Hi there, yep, there is automatic retry, I've just failed to document it in the README. You can specify the number of retries to attempt before flagging as failed with a parameter to the decorator:

@task(retries=3)
def my_task(cqt):
    pass

If you only want to retry on specific exceptions, for example, if you're being rate-limited by an external source, you can use:

from other_api.exceptions import RateLimitExceeded

@task(retries=3, retry_exceptions=[RateLimitExceeded])
def my_task(cqt):
    pass

Hope that helps!

Cheers, Luke