Repository navigation
Conversation
36bfd66 to
d8cfeac
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7253 +/- ##
==========================================
- Coverage 88.76% 88.75% -0.01%
==========================================
Files 153 153
Lines 19949 19946 -3
Branches 2331 2330 -1
==========================================
- Hits 17707 17704 -3
Misses 1945 1945
Partials 297 297
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
This pull request introduces 25 alerts and fixes 1 when merging d8cfeac into fdb4af3 - view on LGTM.com new alerts:
fixed alerts:
|
|
@thedrow need your insight here |
|
@thedrow Do you see a need to ever prevent calling |
thedrow
left a comment
There was a problem hiding this comment.
I haven't read through the code yet but the fundamental problem is that some tasks can run eagerly by forcing them specifically to run eagerly and others can be delayed. If the configuration alone controlled whether a task is applied or applied asynchronously, we could do something like what you're suggesting.
d8cfeac to
5319658
Compare
Documentation of EagerResult.get copied from AsyncResult.get, with following changes: - changed first line - removed warning about sync subtasks - removed warning about backend storing the results - changed description of disable_sync_subtasks parameter
5319658 to
4f9e579
Compare
|
This pull request introduces 1 alert when merging 4f9e579 into df7795f - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts Celery’s eager execution result handling so that EagerResult.get() no longer enforces the “sync subtasks will block” guard (which is appropriate for AsyncResult.get() but breaks eager chains).
Changes:
- Remove the
assert_will_not_block()behavior fromEagerResult.get(). - Deprecate/ignore
disable_sync_subtasksforEagerResult.get()and emit a deprecation warning when it’s passed. - Update the unit test for
EagerResult.get()accordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
celery/result.py |
Changes EagerResult.get() semantics to not enforce sync-subtask blocking checks; adds a deprecation warning path. |
t/unit/tasks/test_result.py |
Updates the EagerResult get() unit test to reflect the new behavior. |
Comments suppressed due to low confidence (4)
t/unit/tasks/test_result.py:964
- EagerResult is being instantiated with arguments in the wrong order:
EagerResult(id, ret_value, state, traceback=None). PassingEagerResult(tid, 'x', 'x', states.SUCCESS)setsstate='x'andtraceback=states.SUCCESS, soget()won't return the expected value. Update the constructor call to passstates.SUCCESSas thestate(and assertget()returns'x'to validate behavior).
self.raising = raising
def test_wait_raises(self):
celery/result.py:1006
- The docstring argument name is inconsistent with the actual parameter (
disable_sync_subtasks) and appears to be a typo (disable_sync_subtask). Update the docstring so the parameter name matches the signature, and consider noting that the argument is deprecated/ignored.
self.on_ready(self)
def then(self, callback, on_error=None, weak=False):
return self.on_ready.then(callback, on_error)
celery/result.py:1013
- EagerResult.get now emits a CDeprecationWarning when
disable_sync_subtasksis passed. There’s no unit test asserting this warning behavior (e.g., viapytest.deprecated_call/pytest.warns), so a future change could unintentionally remove or alter it without detection.
def __reduce__(self):
return self.__class__, self.__reduce_args__()
def __reduce_args__(self):
celery/result.py:1013
EagerResult.get()now warns wheneverdisable_sync_subtasksis provided, but internal callers likeResultSet.join()/GroupResult.get()always passdisable_sync_subtasksthrough explicitly. This can lead to unexpected deprecation warnings in eager mode even when user code never passes the option toEagerResult.get()directly. Consider only warning when a non-default value is passed (e.g.,False) or removing the warning to avoid warning spam from internal calls.
def __reduce__(self):
return self.__class__, self.__reduce_args__()
def __reduce_args__(self):
treszkai
left a comment
There was a problem hiding this comment.
@ChickenBenny Thanks for the thorough review. Fixed according to your requests.
| warnings.warn( | ||
| 'Passing `disable_sync_subtasks` to EagerResult.get has no effect.', | ||
| CDeprecationWarning, stacklevel=2) |
There was a problem hiding this comment.
@ChickenBenny Very true.
Stack inspection turned out fairly concise, so now implemented and tested.
As such, @auvipy's (and Copilot's) fix of warning only when disable_sync_subtasks is False turned out unnecessary.
3132608 to
6a8f308
Compare
…elery#7253) (__file__ failed on Windows)
f5a70f2 to
144cacf
Compare
stack[1].filename != __file__ failed on Windows
cb35091 to
144cacf
Compare
1473d96 to
144cacf
Compare
It technically wasn't a deprecation anyhow, as EagerResult subclassed AsyncResult, so the keyword argument is there to stay.
- documentation of EagerResult.get inspired by AsyncResult.get - remove unused `remaining` assignment in ResultSet.join - old `test_get` (from 2017) assigned `states.SUCCESS` to `traceback`, not `state` (fixed)
e951cf7 to
61c56b3
Compare
|
@auvipy Rebased and squashed commits. |
|
is this PR related to this? #8070 |
Description
EagerResult.get()shouldn't check if it is executed in an async context (UnlikeAsyncResult.get().)The version on
masterprevents a chain from being executed eagerly because_chain.apply()runsresult.get()on the result of each task in the chain. As this result is anEagerResult, thisget()operation fails.I don't see the purpose of
EagerResultever disabling synchronous subtasks, but maybe I'm missing something.Alternative
If that conditional check in
EagerResult.get()is correct, thenresult.get()could be called withdisable_sync_subtasks=Falsein_chain.apply().