Fix when_all hang when some children complete before construction#1150
Fix when_all hang when some children complete before construction#1150passuied wants to merge 1 commit into
Conversation
WhenAllTask.__init__ was resetting _completed_tasks after CompositeTask had already counted pre-completed children, so deferred when_all hung forever in the partial-completion case. Signed-off-by: Patrick Assuied <patrick.assuied@elationhealth.com> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a durabletask when_all(children) hang that occurs when some (but not all) child tasks complete before the WhenAllTask is constructed (deferred fan-in). It aligns WhenAllTask’s construction behavior with CompositeTask’s existing “count pre-completed children” initialization logic and adds regression coverage to prevent reintroduction.
Changes:
- Stop resetting
WhenAllTask’s_completed_tasks/_failed_tasksafterCompositeTask.__init__has already accounted for pre-completed children. - Add unit tests covering partial pre-completion, full pre-completion, and
when_any([when_all(children), timeout])interaction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
dapr/ext/workflow/_durabletask/task.py |
Removes the counter reset in WhenAllTask.__init__ so pre-completed children are retained and when_all can complete correctly. |
tests/ext/workflow/durabletask/test_task.py |
Adds regression tests for deferred when_all with pre-completed children and composition with when_any. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1150 +/- ##
==========================================
+ Coverage 82.76% 82.84% +0.08%
==========================================
Files 123 123
Lines 10123 10121 -2
==========================================
+ Hits 8378 8385 +7
+ Misses 1745 1736 -9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #1149
Description
WhenAllTask.__init__was resetting_completed_tasks/_failed_tasksafterCompositeTask.__init__had already counted children that were complete at construction time. That drops early completions, so deferredwhen_all(children)hangs forever when some but not all children finished beforewhen_allwas built.Changes
WhenAllTask.__init__(keep empty-list fast path)when_any([when_all, timeout])Test plan
uv run pytest tests/ext/workflow/durabletask/test_task.pyRELEASE NOTE: FIX Bug causing
when_allto hang when some child tasks complete beforewhen_allis constructedMade with Cursor