Skip to content

Deliver pending cancellation when an activity thread registers - #1954

Open
yannvr wants to merge 1 commit into
temporalio:mainfrom
yannvr:fix/pending-thread-cancellation
Open

yannvr wants to merge 1 commit into
temporalio:mainfrom
yannvr:fix/pending-thread-cancellation

Conversation

@yannvr

@yannvr yannvr commented Oct 10, 2026

Copy link
Copy Markdown

What changed

A synchronous activity can receive cancellation while waiting for an executor thread. The raiser stores the exception, but thread registration never delivers it, so the cancelled activity still executes. Registration now checks the pending exception under the existing lock and honours shielding.

Registration can now raise before the context manager yields, so it also moves inside the existing cleanup guard. The thread id is cleared on that path, keeping the executor thread available for the next activity.

Validation

  • The new pre-start cancellation regression fails on unchanged main at fc5299b.
  • Five focused tests cover pre-start cancellation, shielding, active cancellation and post-return thread reuse; all pass.
  • Eight existing worker tests pass with the local dev server, including thread cancellation and shutdown.
  • Broader worker/activity-environment checks with the time-skipping server: 59 passed, 10 skipped.
  • poe lint passes (Ruff formatting/imports, Pyright, mypy, basedpyright and docstyle).

Python source was tested with Python 3.13.16 and the published 1.33.0 native bridge; no Rust code changes. CI should verify the current bridge build.

Prepared with OpenAI Codex.

@yannvr
yannvr requested a review from a team as a code owner October 10, 2026 14:01
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants