From e7d329b1f5f3457c3e7aa23ee61fb4e2ad6ad0c8 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Wed, 9 Apr 2025 20:59:42 -0400 Subject: [PATCH 1/2] Assert external_cancel unused --- temporalio/worker/_workflow_instance.py | 1 + 1 file changed, 1 insertion(+) diff --git a/temporalio/worker/_workflow_instance.py b/temporalio/worker/_workflow_instance.py index 2809e788..6c4702a5 100644 --- a/temporalio/worker/_workflow_instance.py +++ b/temporalio/worker/_workflow_instance.py @@ -1594,6 +1594,7 @@ def apply_child_cancel_error() -> None: # If the cancel command is for external workflow, we # have to add a seq and mark it pending if cancel_command.HasField("request_cancel_external_workflow_execution"): + assert False, "request_cancel_external_workflow_execution" cancel_seq = self._next_seq("external_cancel") cancel_command.request_cancel_external_workflow_execution.seq = ( cancel_seq From 0b39a2e8ea7cd39fd8aaa21184e129c57e8b9428 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Wed, 9 Apr 2025 21:20:35 -0400 Subject: [PATCH 2/2] Don't shield --- temporalio/worker/_workflow_instance.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/temporalio/worker/_workflow_instance.py b/temporalio/worker/_workflow_instance.py index 6c4702a5..8563fbed 100644 --- a/temporalio/worker/_workflow_instance.py +++ b/temporalio/worker/_workflow_instance.py @@ -1610,9 +1610,7 @@ async def run_child() -> Any: while True: assert handle try: - # We have to shield because we don't want the future itself - # to be cancelled - return await asyncio.shield(handle._result_fut) + return await handle._result_fut except asyncio.CancelledError: apply_child_cancel_error() @@ -1626,9 +1624,7 @@ async def run_child() -> Any: # Wait on start before returning while True: try: - # We have to shield because we don't want the future itself - # to be cancelled - await asyncio.shield(handle._start_fut) + await handle._start_fut return handle except asyncio.CancelledError: apply_child_cancel_error()