Skip to content

Preserve task cancellation when waits complete concurrently - #2149

Draft
VegetarianOrc wants to merge 3 commits into
amazzeo/workflow-activation-batch-onlyfrom
amazzeo/workflow-wait-condition-cancellation
Draft

VegetarianOrc wants to merge 3 commits into
amazzeo/workflow-activation-batch-onlyfrom
amazzeo/workflow-wait-condition-cancellation

Conversation

@VegetarianOrc

@VegetarianOrc VegetarianOrc commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

Add the internal PRESERVE_TASK_CANCELLATION flag (4), off by default. It makes workflow.wait_condition respect task shielding and preserves task cancellation when a condition or a Temporal operation completes concurrently. It also retains a cancellation request if it arrives before the primary task is created. The new flag does not enable batching; histories using the original single-batch flag keep their existing behavior.

This incorporates the task-local wait_condition approach from #2124.

Why?

The original single-batch flag inferred cancellation from workflow-wide state, which could cancel a shielded wait. In other cases, retrying an await could return a completed result and swallow task cancellation. A separate history-recorded flag lets workers adopt these fixes without changing replay behavior for existing histories.

Checklist

  1. Closes: N/A.

  2. How was this tested:

    • Regression tests cover shielded cleanup, cancellation racing with condition readiness or child completion, timer options, and replay.
    • Full poe test suite on Python 3.12.13: 1,892 passed, 10 skipped.
  3. Any docs updates needed? No public API docs need updating. A changelog fragment describes the opt-in behavior.

@VegetarianOrc VegetarianOrc changed the title amazzeo/workflow wait condition cancellation Preserve task cancellation when waits complete concurrently Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant