8000 Replacing a task with a chain which contains a group now returns a result instead of hanging by auvipy · Pull Request #9604 · celery/celery · GitHub
[go: up one dir, main page]

Skip to content

Replacing a task with a chain which contains a group now returns a result instead of hanging #9604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

auvipy
Copy link
Member
@auvipy auvipy commented Mar 11, 2025

Description

The following task

@shared_task(bind=True)
def replace_with_chain_which_contains_a_group(self):
    return self.replace(chain(add.s(1, 2), group(add.s(1), add.s(1))))

did not return a result. This PR fixes the issue and now a result is returned correctly instead of hanging until timeout occurs.

Copy link
Member Author
@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

may be we should also add some unit test for this?

Copy link
codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.50%. Comparing base (778b009) to head (f37a528).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
celery/app/task.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9604      +/-   ##
==========================================
- Coverage   78.51%   78.50%   -0.01%     
==========================================
  Files         153      153              
  Lines       19127    19129       +2     
  Branches     2533     2534       +1     
==========================================
  Hits        15018    15018              
+ Misses       3821     3820       -1     
- Partials      288      291       +3     
Flag Coverage Δ
unittests 78.48% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@auvipy
Copy link
Member Author
auvipy commented Mar 11, 2025

@Nusnus boss, need some help here, can you point me where exactly to adjust the unit test for this :D forgot many thing

@auvipy auvipy requested a review from Nusnus March 13, 2025 06:19
@auvipy auvipy added this to the 5.5.0 milestone Mar 13, 2025
@auvipy
Copy link
Member Author
auvipy commented Mar 13, 2025

Integration tests and docker build failures are not related to this specific pr

Copy link
Member
@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

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

@auvipy

@Nusnus boss, need some help here, can you point me where exactly to adjust the unit test for this :D forgot many thing

Np, I got your back!

Check this: https://github.com/celery/celery/blob/main/t/unit/tasks/test_canvas.py

@auvipy auvipy modified the milestones: 5.5.0, 5.7.0 Apr 28, 2025
@auvipy auvipy requested a review from Copilot April 28, 2025 04:15
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a hanging task by ensuring that a chain containing a group returns a result by appending the accumulate callback appropriately.

  • Introduces a new task (replace_with_chain_which_contains_a_group) that wraps a chain with a group.
  • Updates tests in t/integration/test_canvas.py to validate the new behavior.
  • Adjusts celery/app/task.py to append the accumulate callback when a chain’s final task is a group.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
t/integration/test_canvas.py Adds test for replacing a task with a chain that contains a group.
t/integration/tasks.py Introduces the new task replace_with_chain_which_contains_a_group.
celery/app/task.py Updates the replace method to attach the accumulate callback to groups in chains.
Comments suppressed due to low confidence (1)

t/integration/tasks.py:157

  • [nitpick] The function name 'replace_with_chain_which_contains_a_group' is quite lengthy; consider simplifying it to 'replace_with_chain_containing_group' for improved readability.
def replace_with_chain_which_contains_a_group(self):

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

Successfully merging this pull request may close these issues.

2 participants
0