Skip to content

[FROZEN][Bridge] Let a plugin finish when a Worker's async with block ends. - #129

Closed
moetemp wants to merge 2 commits into
mainfrom
moe/bridge/f1-worker-exit-no-cancel
Closed

moetemp wants to merge 2 commits into
mainfrom
moe/bridge/f1-worker-exit-no-cancel

Conversation

@moetemp

@moetemp moetemp commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR stops Worker.__aexit__ from cancelling the Worker's run task, so a plugin finishes its work and the caller isn't cancelled later. __aexit__ marks that the block is being left and awaits the run task. A cancel of the caller during exit still raises. An error from a plugin's work after the Worker stopped is raised from __aexit__ when the block raised nothing.

Why?

Any plugin with work after the Worker stops, like a flush, lost it, and the caller's next await raised CancelledError. The streams plugin's stop flush found it, but the bug isn't specific to streams.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

Ran the new test in tests/test_plugins.py, plus the Worker and activity suites.

Leaving the block cancelled the Worker's run task while a plugin's run_worker still had work after shutdown, and the run task then cancelled the caller's task, so the next await outside the block raised CancelledError.
Once exit waits for the run task, a cancel of the caller reached the plugin and was swallowed, and an error from a plugin's work after the Worker stopped was dropped. Setting the exit flag before shutdown also returns an error raised as shutdown completes as itself.
@moetemp
moetemp marked this pull request as draft October 12, 2026 06:58
@moetemp moetemp changed the title [Bridge] Let a plugin finish when a Worker's async with block ends. [FROZEN][Bridge] Let a plugin finish when a Worker's async with block ends. Oct 20, 2026
@moetemp

moetemp commented Oct 22, 2026

Copy link
Copy Markdown
Owner Author

Closed as unused. Jetty and Bridge are frozen, and the Brook v4 stack doesn't build on this PR. The branch stays, so this PR can be reopened.

@moetemp moetemp closed this Oct 22, 2026
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