Nandu Ajith
Nandu Ajith

Reputation: 36

Celery class based task is not retrying

I am having a class-based celery task defined as follows:

class MyTask(Task):  
    name = "MY_TASK"
    autoretry_for = (Exception, )
    retry_kwargs = {'max_retries': 5}
    retry_backoff = True
    retry_backoff_max = 700
    retry_jitter = False

    def run(self, service, *args, **kwargs):
        pass
        # do something
        # return some value

    def on_failure(self, exc, task_id, args, kwargs, einfo):
        # can extend failure method if needed
        super().on_failure(exc, task_id, args, kwargs, einfo)


app.tasks.register(MyTask())

My task is executing perfectly. But when an exception occurs, the task is not retried

My celery version is 4.4.2
And python version is 3.8.2

Upvotes: 1

Views: 283

Answers (1)

Nandu Ajith
Nandu Ajith

Reputation: 36

This is a bug in celery and was fixed in PR: https://github.com/celery/celery/pull/6233

Upvotes: 0

Related Questions