Skip to content

Added a default value for retries in worker.strategy.#5945

Merged
auvipy merged 2 commits into
celery:masterfrom
bajubullet:fix_retries_issue
Feb 28, 2020
Merged

Added a default value for retries in worker.strategy.#5945
auvipy merged 2 commits into
celery:masterfrom
bajubullet:fix_retries_issue

Conversation

@abhishekakamai

Copy link
Copy Markdown
Contributor

I was facing an issue when adding tasks directly to rabbitmq using pika instead of calling task.apply_async. The issue was the self.retry mechanism was failing. In app/tasks.py the line
retries = request.retries + 1 was causing the issue. On further tracing I figured out that it was because the default .get value (None) was getting passed through this function and was raising

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Note: Before submitting this pull request, please review our contributing
guidelines
.

Description

I was facing an issue when adding tasks directly to rabbitmq
using pika instead of calling task.apply_async. The issue was
the self.retry mechanisum was failing. In app/tasks.py the line
`retries = request.retries + 1` was causing the issue. On further
tracing I figured out that it was because the default .get value
(None) was getting passed through this function and was raising
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

@auvipy auvipy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see an updated unit test for this

@auvipy auvipy added this to the 4.4.x milestone Jan 31, 2020
@bajubullet

bajubullet commented Jan 31, 2020

Copy link
Copy Markdown

I actually wanted to create an issue for the same but the create issue button said that its for maintainers only.

Also I have a question, should I change retries value here or update where the retry value is actually getting updated in task.py here or in the update function here.

If the current PR is fine, let me know. I'll add the necessary test cases.

@auvipy

auvipy commented Jan 31, 2020

Copy link
Copy Markdown
Member

generally, we don't merge PR without proper unit tests to avoid regression

@codecov

codecov Bot commented Feb 3, 2020

Copy link
Copy Markdown

Codecov Report

Merging #5945 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5945   +/-   ##
=======================================
  Coverage   83.21%   83.21%           
=======================================
  Files         145      145           
  Lines       17130    17130           
  Branches     2110     2110           
=======================================
  Hits        14254    14254           
  Misses       2661     2661           
  Partials      215      215
Impacted Files Coverage Δ
celery/worker/strategy.py 88.23% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ee6c3b...d3a6880. Read the comment docs.

@bajubullet

Copy link
Copy Markdown

Added test cases for retries as you asked. Let me know if anything else is required.

@bajubullet

Copy link
Copy Markdown

@auvipy any update on this?

@auvipy

auvipy commented Feb 7, 2020

Copy link
Copy Markdown
Member

you need to make the Travis green