diff --git a/changelog/added/tumbling-job-basket.md b/changelog/added/tumbling-job-basket.md index 1c96ceeb1..3ecf15c76 100644 --- a/changelog/added/tumbling-job-basket.md +++ b/changelog/added/tumbling-job-basket.md @@ -1 +1,8 @@ -Add flag-controlled workflow activation processing (workflow logic flag 4). With the flag, signal and update handlers no longer run before other jobs delivered in the same workflow task. Cancellation also takes priority over a condition, child workflow result or Nexus operation result that becomes ready in the same workflow task as the cancellation. Unlike flag 2, flag 4 cancels only the task that receives the cancellation, so a shielded `workflow.wait_condition` can finish. The flag remains disabled by default in this release. +Add flag-controlled workflow activation processing (workflow logic flag 4). With the flag, signal and update handlers no longer run before other jobs delivered in the same workflow task. The flag remains disabled by default in this release. +With flag 4, cancellation takes priority over a condition, child workflow result or Nexus operation result that becomes ready in the same workflow task. +Unlike flag 2, flag 4 cancels only the task that receives the cancellation. A `workflow.wait_condition()` call that is shielded or in another task, such as a signal or update handler, can therefore finish after cancellation. +With flag 4, a signal to an external or child workflow raises `asyncio.CancelledError` when it completes in the same workflow task as a workflow cancellation. Previously, a successful signal call returned and the workflow did not see the cancellation. +With flag 4, cancelling a child workflow or Nexus operation handle in the workflow task that delivers its result can take priority over the result. Awaiting the handle then raises `asyncio.CancelledError` instead of returning the result. +With flag 4, `workflow.all_handlers_finished()` can return `False` more often in the workflow task where a signal handler finishes. Use `await workflow.wait_condition(workflow.all_handlers_finished)` instead. +With flag 4, signal and update handlers do not run if applying another job in the same workflow task fails the workflow. +With flag 4 on Python 3.11, `workflow.wait_condition()` timeouts round to the nearest millisecond, as on Python 3.12 and later. diff --git a/temporalio/_workflow_context.py b/temporalio/_workflow_context.py index 47d9ef562..e35b6d6e6 100644 --- a/temporalio/_workflow_context.py +++ b/temporalio/_workflow_context.py @@ -38,6 +38,11 @@ class _WorkflowLogicFlag(IntEnum): # cancellation, send a cancel request to it. Flag 2 sends none. # Added on 2026-11-30. # Not enabled by default. + # TODO: When enabling APPLY_ACTIVATION_JOBS_BEFORE_RUNNING_TASKS by default, + # remove the explicit overrides for this flag from the tests. The changelog + # must also name the minimum SDK version that replays histories with this + # flag, because older SDKs can give different replay results without a + # nondeterminism error. Then remove this reminder. APPLY_ACTIVATION_JOBS_BEFORE_RUNNING_TASKS = 4