Skip to content

Commit 429fbe8

Browse files
committed
Poll for completed before returning handle
1 parent ae6acec commit 429fbe8

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

temporalio/client.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6146,13 +6146,19 @@ async def _start_workflow_update_with_start(
61466146
update_response.stage
61476147
>= temporalio.api.enums.v1.UpdateWorkflowExecutionLifecycleStage.UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED
61486148
):
6149-
return WorkflowUpdateHandle(
6150-
client=self._client,
6151-
id=update_req.request.meta.update_id,
6152-
workflow_id=start_input.id,
6153-
workflow_run_id=start_response.run_id,
6154-
known_outcome=known_outcome,
6155-
)
6149+
break
6150+
6151+
handle = WorkflowUpdateHandle(
6152+
client=self._client,
6153+
id=update_req.request.meta.update_id,
6154+
workflow_id=start_input.id,
6155+
workflow_run_id=start_response.run_id,
6156+
known_outcome=known_outcome,
6157+
)
6158+
if update_input.wait_for_stage == WorkflowUpdateStage.COMPLETED:
6159+
await handle._poll_until_outcome()
6160+
6161+
return handle
61566162

61576163
### Async activity calls
61586164

tests/worker/test_update_with_start.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ class ExpectErrorWhenWorkflowExists(Enum):
7171
NO = "no"
7272

7373

74-
class ExpectUpdateResultInResponse(Enum):
75-
YES = "yes"
76-
NO = "no"
77-
78-
7974
class UpdateHandlerType(Enum):
8075
NON_BLOCKING = "non-blocking"
8176
BLOCKING = "blocking"
@@ -100,7 +95,6 @@ async def test_non_blocking_update_with_must_create_workflow_semantics(
10095
UpdateHandlerType.NON_BLOCKING,
10196
wait_for_stage,
10297
WorkflowIDConflictPolicy.FAIL,
103-
ExpectUpdateResultInResponse.YES,
10498
ExpectErrorWhenWorkflowExists.YES,
10599
)
106100

@@ -117,7 +111,6 @@ async def test_non_blocking_update_with_get_or_create_workflow_semantics(
117111
UpdateHandlerType.NON_BLOCKING,
118112
wait_for_stage,
119113
WorkflowIDConflictPolicy.USE_EXISTING,
120-
ExpectUpdateResultInResponse.YES,
121114
ExpectErrorWhenWorkflowExists.NO,
122115
)
123116

@@ -134,10 +127,6 @@ async def test_blocking_update_with_get_or_create_workflow_semantics(
134127
UpdateHandlerType.BLOCKING,
135128
wait_for_stage,
136129
WorkflowIDConflictPolicy.USE_EXISTING,
137-
{
138-
WorkflowUpdateStage.ACCEPTED: ExpectUpdateResultInResponse.NO,
139-
WorkflowUpdateStage.COMPLETED: ExpectUpdateResultInResponse.YES,
140-
}[wait_for_stage],
141130
ExpectErrorWhenWorkflowExists.NO,
142131
)
143132

@@ -148,7 +137,6 @@ async def _do_test(
148137
update_handler_type: UpdateHandlerType,
149138
wait_for_stage: WorkflowUpdateStage,
150139
id_conflict_policy: WorkflowIDConflictPolicy,
151-
expect_update_result_in_response: ExpectUpdateResultInResponse,
152140
expect_error_when_workflow_exists: ExpectErrorWhenWorkflowExists,
153141
):
154142
await self._do_execute_update_test(
@@ -164,7 +152,6 @@ async def _do_test(
164152
update_handler_type,
165153
wait_for_stage,
166154
id_conflict_policy,
167-
expect_update_result_in_response,
168155
)
169156

170157
async def _do_execute_update_test(
@@ -254,7 +241,6 @@ async def _do_start_update_test(
254241
update_handler_type: UpdateHandlerType,
255242
wait_for_stage: WorkflowUpdateStage,
256243
id_conflict_policy: WorkflowIDConflictPolicy,
257-
expect_update_result_in_response: ExpectUpdateResultInResponse,
258244
):
259245
update_handler = (
260246
WorkflowForUpdateWithStartTest.my_blocking_update
@@ -284,10 +270,7 @@ async def _do_start_update_test(
284270
wait_for_stage=wait_for_stage,
285271
start_workflow_operation=start_op,
286272
)
287-
with self.assert_network_call(
288-
expect_update_result_in_response == ExpectUpdateResultInResponse.NO
289-
):
290-
assert await update_handle.result() == "update-result-1"
273+
assert await update_handle.result() == "update-result-1"
291274

292275
@contextmanager
293276
def assert_network_call(

0 commit comments

Comments
 (0)