From 104b5e20d6d7ec158c0cab38bc0dcd2ef876a429 Mon Sep 17 00:00:00 2001 From: Drew Hoskins Date: Fri, 30 Aug 2024 18:43:44 -0700 Subject: [PATCH] Document all_handlers_finished in the README --- updates_and_signals/safe_message_handlers/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/updates_and_signals/safe_message_handlers/README.md b/updates_and_signals/safe_message_handlers/README.md index 44bb9457..7d727af3 100644 --- a/updates_and_signals/safe_message_handlers/README.md +++ b/updates_and_signals/safe_message_handlers/README.md @@ -4,9 +4,9 @@ This sample shows off important techniques for handling signals and updates, aka * Here, using workflow.wait_condition, signal and update handlers will only operate when the workflow is within a certain state--between cluster_started and cluster_shutdown. * You can run start_workflow with an initializer signal that you want to run before anything else other than the workflow's constructor. This pattern is known as "signal-with-start." -* Message handlers can block and their actions can be interleaved with one another and with the main workflow. This can easily cause bugs, so we use a lock to protect shared state from interleaved access. -* Message handlers should also finish before the workflow run completes. One option is to use a lock. -* An "Entity" workflow, i.e. a long-lived workflow, periodically "continues as new". It must do this to prevent its history from growing too large, and it passes its state to the next workflow. You can check `workflow.info().is_continue_as_new_suggested()` to see when it's time. Just make sure message handlers have finished before doing so. +* Message handlers can block and their actions can be interleaved with one another and with the main workflow. This can easily cause bugs, so you can use a lock to protect shared state from interleaved access. +* An "Entity" workflow, i.e. a long-lived workflow, periodically "continues as new". It must do this to prevent its history from growing too large, and it passes its state to the next workflow. You can check `workflow.info().is_continue_as_new_suggested()` to see when it's time. +* Most people want their message handlers to finish before the workflow run completes or continues as new. Use `await workflow.wait_condition(lambda: workflow.all_handlers_finished())` to achieve this. * Message handlers can be made idempotent. See update `ClusterManager.assign_nodes_to_job`. To run, first see [README.md](../../README.md) for prerequisites.