Skip to content

Remove disable_sync_subtasks from the EagerResult.get method. - #8070

Draft
YPCrumble wants to merge 3 commits into
celery:mainfrom
YPCrumble:feature/remove-disable-sync-subtasks-for-eager-result
Draft

YPCrumble wants to merge 3 commits into
celery:mainfrom
YPCrumble:feature/remove-disable-sync-subtasks-for-eager-result

Conversation

@YPCrumble

Copy link
Copy Markdown

Fixes #6072.

@auvipy this draft is what I was suggesting for EagerResult. Because the task is run "locally" it means that the issues with synchronous subtasks should not apply. For instance, the docs suggest that this "may even cause a deadlock if the worker pool is exhausted", but because an EagerResult created by apply is not sent to the worker pool this isn't possible.

I suppose there's a chance that EagerResult could potentially be created somewhere other than the apply function, but I couldn't find an instance of this in the code to date. As long as EagerResult is never a result of a task generated by the worker pool I think this PR makes sense, because there is no chance of deadlock.

If this PR makes sense I would be happy to update the docs and warnings, as well as improve the docstrings.

Thanks again for maintaining Celery, and I'd love to hear your feedback on this PR!

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

Description

@auvipy
auvipy requested review from auvipy and thedrow February 17, 2023 05:40

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

demonstrating a failing test case, along with the proposed removal of disable_sync_subtasks check is needed to properly understand the scenario

@auvipy auvipy added this to the 5.6.0 milestone Feb 3, 2025
@auvipy auvipy modified the milestones: 5.6.0, 5.7.0 Jun 17, 2025
@auvipy
auvipy requested a lite review from Copilot and removed request for thedrow August 26, 2026 17:57
@auvipy auvipy modified the milestones: 5.7.0, 5.8.0 Aug 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts EagerResult.get() (used for results produced by eager/local execution via Task.apply) to no longer enforce the synchronous-subtask blocking guard (assert_will_not_block()), addressing issue #6072 where eager chains could incorrectly raise E_WOULDBLOCK.

Changes:

  • Removed disable_sync_subtasks handling (and the assert_will_not_block() call) from EagerResult.get().
  • Simplified EagerResult.get() signature to accept only timeout, propagate, and **kwargs.
Suppressed comments (1)

celery/result.py:1066

  • This change removes the assert_will_not_block() behavior for eager results, but there are existing unit tests that currently expect EagerResult.get() to raise RuntimeError when task_join_will_block() is true (e.g. t/unit/tasks/test_result.py::test_get_sync_subtask_option). The tests should be updated to reflect the new intended behavior and prevent regressions.
    def get(self, timeout=None, propagate=True, **kwargs):
        if self.successful():
            return self.result
        elif self.state in states.PROPAGATE_STATES:
            if propagate:
                raise self.result if isinstance(
                    self.result, Exception) else Exception(self.result)
            return self.result

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread celery/result.py
if disable_sync_subtasks:
assert_will_not_block()

def get(self, timeout=None, propagate=True, **kwargs):

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling get() on a synchronous chain result triggers E_WOULDBLOCK

3 participants