Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

request.retries comes in as null in the celery worker #124

Open
edu2004eu opened this issue Jan 23, 2019 · 2 comments
Open

request.retries comes in as null in the celery worker #124

edu2004eu opened this issue Jan 23, 2019 · 2 comments

Comments

@edu2004eu
Copy link

I'm trying to retry tasks if they fail, using a back-off mechanism:

self.retry(exc=e, countdown=int(random.uniform(2, 4) ** self.request.retries))

When sending tasks from Python's celery, everything works well. Using celery-php to send tasks throws an error when reaching the code above, saying that self.request.retries is None.

Python's celery automatically sends request.retries as 0 on the first schedule of the task.

@Krismix1
Copy link

I am also trying to implement the retry and having the same issue.

@edu2004eu did you have any progress on the following issue?

@edu2004eu
Copy link
Author

I am checking whether request.retries is set in the worker, and if not, I set it to 0. My worker is Python, so I have:

    if self.request.retries is None:
        self.request.retries = 0

    self.retry(exc=e, countdown=int(random.uniform(2, 4) ** self.request.retries))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants