Skip to content

Commit d8a05ab

Browse files
committed
Revert "Emit unfinished handler warnings separately for cancellation"
This reverts commit 87f540e.
1 parent da6566e commit d8a05ab

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

temporalio/worker/_workflow_instance.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,20 +429,15 @@ def activate(
429429
f"Failed converting activation exception: {inner_err}"
430430
)
431431

432-
def is_non_cancellation_completion(command):
432+
def is_completion(command):
433433
return (
434434
command.HasField("complete_workflow_execution")
435435
or command.HasField("continue_as_new_workflow_execution")
436436
or command.HasField("fail_workflow_execution")
437+
or command.HasField("cancel_workflow_execution")
437438
)
438439

439-
# We do also warn in the case of workflow cancellation, but this is done
440-
# when handling the workflow cancellation, since we also cancel update
441-
# handlers at that time.
442-
if any(
443-
is_non_cancellation_completion(c)
444-
for c in self._current_completion.successful.commands
445-
):
440+
if any(map(is_completion, self._current_completion.successful.commands)):
446441
self._warn_if_unfinished_handlers()
447442

448443
return self._current_completion
@@ -1856,7 +1851,6 @@ async def _run_top_level_workflow_function(self, coro: Awaitable[None]) -> None:
18561851
err
18571852
):
18581853
self._add_command().cancel_workflow_execution.SetInParent()
1859-
self._warn_if_unfinished_handlers()
18601854
# Cancel update tasks, so that the update caller receives an
18611855
# update failed error. We do not currently cancel signal tasks
18621856
# since (a) doing so would require a workflow flag and (b) the

tests/worker/test_workflow.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5584,16 +5584,9 @@ class _UnfinishedHandlersOnWorkflowTerminationTest:
55845584
async def test_warning_is_issued_on_exit_with_unfinished_handler(
55855585
self,
55865586
):
5587-
warning_emitted = await self._run_workflow_and_get_warning()
5588-
if self.workflow_termination_type == "-cancellation-":
5589-
# All paths through this test for which the workflow is cancelled result
5590-
# in the warning being emitted.
5591-
assert warning_emitted
5592-
else:
5593-
# Otherwise, the warning is emitted iff the workflow does not wait for handlers to finish.
5594-
assert warning_emitted == (
5595-
self.handler_waiting == "-no-wait-all-handlers-finish-"
5596-
)
5587+
assert await self._run_workflow_and_get_warning() == (
5588+
self.handler_waiting == "-no-wait-all-handlers-finish-"
5589+
)
55975590

55985591
async def _run_workflow_and_get_warning(self) -> bool:
55995592
workflow_id = f"wf-{uuid.uuid4()}"

0 commit comments

Comments
 (0)