@@ -429,15 +429,20 @@ def activate(
429429 f"Failed converting activation exception: { inner_err } "
430430 )
431431
432- def is_completion (command ):
432+ def is_non_cancellation_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" )
438437 )
439438
440- if any (map (is_completion , self ._current_completion .successful .commands )):
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+ ):
441446 self ._warn_if_unfinished_handlers ()
442447
443448 return self ._current_completion
@@ -1851,6 +1856,7 @@ async def _run_top_level_workflow_function(self, coro: Awaitable[None]) -> None:
18511856 err
18521857 ):
18531858 self ._add_command ().cancel_workflow_execution .SetInParent ()
1859+ self ._warn_if_unfinished_handlers ()
18541860 # Cancel update tasks, so that the update caller receives an
18551861 # update failed error. We do not currently cancel signal tasks
18561862 # since (a) doing so would require a workflow flag and (b) the
0 commit comments