Skip to content

Conversation

@kumuthu53
Copy link
Contributor

Description

I got the following error when trying to execute nested chords while using django-celery-results with a Redis backend.

[2025-10-16 03:37:07,619: ERROR/ForkPoolWorker-1] Chord '2be3556e-7689-49c4-b41d-e3b47581e26c' raised: AttributeError("'DisabledBackend' object has no attribute '_restore_group'")
Traceback (most recent call last):
  File "/home/kumuthu/projects/lynxx/itts_ugo/venv/lib/python3.12/site-packages/celery/backends/redis.py", line 501, in on_chord_part_return
    header_result = GroupResult.restore(gid)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kumuthu/projects/lynxx/itts_ugo/venv/lib/python3.12/site-packages/celery/result.py", line 980, in restore
    return backend.restore_group(id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kumuthu/projects/lynxx/itts_ugo/venv/lib/python3.12/site-packages/celery/backends/base.py", line 655, in restore_group
    meta = self.get_group_meta(group_id, cache=cache)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kumuthu/projects/lynxx/itts_ugo/venv/lib/python3.12/site-packages/celery/backends/base.py", line 648, in get_group_meta
    meta = self._restore_group(group_id)
           ^^^^^^^^^^^^^^^^^^^
AttributeError: 'DisabledBackend' object has no attribute '_restore_group'. Did you mean: 'restore_group'?

After investigation, I found that this was because the GroupResult.restore method was using an incorrect Celery app instead of the Celery app that is defined in the Django project. This incorrect app does not have the result backend defined and therefore causes the above error.

    @classmethod
    def restore(cls, id, backend=None, app=None):
        """Restore previously saved group result."""
        app = app or (
            cls.app if not isinstance(cls.app, property) else current_app
        )
        backend = backend or app.backend
        return backend.restore_group(id)

This is because the RedisBackend.on_chord_part_return does not pass in the correct Celery app to GroupResult.restore.

header_result = GroupResult.restore(gid)

Therefore, I've made this pull request so that RedisBackend.on_chord_part_return will pass in the correct Celery app to GroupResult.restore.

header_result = GroupResult.restore(gid, app=app)

This has fixed this bug, and we are now able to run nested chords.

Related Issue

The following issue describes the same bug.

#9006

@kumuthu53
Copy link
Contributor Author

The failing test has nothing to do with my changes

image

@auvipy
Copy link
Member

auvipy commented Oct 16, 2025

flake8 is not test.

@auvipy auvipy requested review from auvipy and Copilot October 16, 2025 07:34
Copy link
Contributor

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

Fix nested chords failing with django-celery-results when using a Redis result backend by ensuring GroupResult.restore uses the correct Celery app/backend.

  • Pass the current app into GroupResult.restore within RedisBackend.on_chord_part_return.
  • Prevents usage of a DisabledBackend during group restoration, fixing AttributeError in nested chord flows.

@Nusnus Nusnus marked this pull request as draft October 16, 2025 09:12
Copy link
Member

@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.

=========================== short test summary info ============================
FAILED t/unit/backends/test_redis.py::test_RedisBackend_chords_complex::test_on_chord_part_return[True] - AssertionError: expected call not found.
Expected: restore('gid1')
Actual: restore('gid1', app=<Celery celery.tests at 0x7f0786f72210>)
FAILED t/unit/backends/test_redis.py::test_RedisBackend_chords_complex::test_on_chord_part_return[False] - AssertionError: expected call not found.
Expected: restore('gid1')
Actual: restore('gid1', app=<Celery celery.tests at 0x7f0786e92180>)
= 2 failed, 3508 passed, 10 skipped, 3 xfailed, 60 warnings, 28958 subtests passed in 141.53s (0:02:21) =
3.12-unit: 185376 C exit 1 (

@auvipy auvipy added this to the 5.6.x milestone Oct 21, 2025
@kumuthu53 kumuthu53 force-pushed the main branch 2 times, most recently from e65e0a0 to bf695fc Compare October 22, 2025 05:57
@kumuthu53
Copy link
Contributor Author

pytest output

The aforementioned errors have been resolved.

==================================================================== 3381 passed, 27 skipped, 3 xfailed, 59 warnings, 28958 subtests passed in 105.40s (0:01:45) =====================================================================

@kumuthu53 kumuthu53 requested a review from auvipy October 23, 2025 04:18
@auvipy auvipy modified the milestones: 5.6.x, 5.6.0 Oct 23, 2025
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.68%. Comparing base (26bee54) to head (bac9cdc).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9950      +/-   ##
==========================================
- Coverage   78.68%   78.68%   -0.01%     
==========================================
  Files         153      153              
  Lines       19312    19312              
  Branches     2214     2214              
==========================================
- Hits        15196    15195       -1     
  Misses       3817     3817              
- Partials      299      300       +1     
Flag Coverage Δ
unittests 78.66% <100.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 auvipy marked this pull request as ready for review October 23, 2025 04:44
@auvipy
Copy link
Member

auvipy commented Oct 25, 2025

can you please rebase? can not update the branch as your work is based off the main branch of your fork.

@Nusnus Nusnus marked this pull request as draft October 26, 2025 00:02
@kumuthu53
Copy link
Contributor Author

@auvipy, I have rebased as requested.

@auvipy auvipy marked this pull request as ready for review October 26, 2025 06:31
@auvipy auvipy merged commit 2aebae5 into celery:main Oct 26, 2025
107 checks passed
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