@@ -429,15 +429,20 @@ def activate(
429
429
f"Failed converting activation exception: { inner_err } "
430
430
)
431
431
432
- def is_completion (command ):
432
+ def is_non_cancellation_completion (command ):
433
433
return (
434
434
command .HasField ("complete_workflow_execution" )
435
435
or command .HasField ("continue_as_new_workflow_execution" )
436
436
or command .HasField ("fail_workflow_execution" )
437
- or command .HasField ("cancel_workflow_execution" )
438
437
)
439
438
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
+ ):
441
446
self ._warn_if_unfinished_handlers ()
442
447
443
448
return self ._current_completion
@@ -1851,6 +1856,7 @@ async def _run_top_level_workflow_function(self, coro: Awaitable[None]) -> None:
1851
1856
err
1852
1857
):
1853
1858
self ._add_command ().cancel_workflow_execution .SetInParent ()
1859
+ self ._warn_if_unfinished_handlers ()
1854
1860
# Cancel update tasks, so that the update caller receives an
1855
1861
# update failed error. We do not currently cancel signal tasks
1856
1862
# since (a) doing so would require a workflow flag and (b) the
0 commit comments