Skip to content

Commit 11f2912

Browse files
authored
Handle empty-list in compound tasks (#317)
1 parent d2786e0 commit 11f2912

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

azure/durable_functions/models/Task.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def __init__(self, tasks: List[TaskBase], compound_action_constructor=None):
159159
self.completed_tasks: List[TaskBase] = []
160160
self.children = tasks
161161

162+
if len(self.children) == 0:
163+
self.state = TaskState.SUCCEEDED
164+
162165
def handle_completion(self, child: TaskBase):
163166
"""Manage sub-task completion events.
164167

tests/orchestrator/test_task_any.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ def generator_function(context):
1414
except:
1515
return "exception"
1616

17+
def generator_function_no_activity(context):
18+
yield context.task_any([])
19+
return "Done!"
20+
21+
def test_continues_on_zero_inner_tasks():
22+
context_builder = ContextBuilder()
23+
result = get_orchestration_state_result(
24+
context_builder, generator_function_no_activity)
25+
expected_state = base_expected_state("Done!")
26+
expected_state._is_done = True
27+
expected = expected_state.to_json()
28+
assert_orchestration_state_equals(expected, result)
29+
1730
def test_continues_on_zero_results():
1831
context_builder = ContextBuilder()
1932
result = get_orchestration_state_result(

0 commit comments

Comments
 (0)