Repository navigation
Conversation
auvipy
requested changes
Feb 27, 2023
auvipy
left a comment
Member
There was a problem hiding this comment.
demonstrating a failing test case, along with the proposed removal of disable_sync_subtasks check is needed to properly understand the scenario
Contributor
There was a problem hiding this comment.
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_subtaskshandling (and theassert_will_not_block()call) fromEagerResult.get(). - Simplified
EagerResult.get()signature to accept onlytimeout,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 expectEagerResult.get()to raiseRuntimeErrorwhentask_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.
| if disable_sync_subtasks: | ||
| assert_will_not_block() | ||
|
|
||
| def get(self, timeout=None, propagate=True, **kwargs): |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 anEagerResultcreated byapplyis not sent to the worker pool this isn't possible.I suppose there's a chance that
EagerResultcould potentially be created somewhere other than theapplyfunction, but I couldn't find an instance of this in the code to date. As long asEagerResultis 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