Repository navigation
[Async stack 3/6] Dispatch cleanup for coroutine orchestrators - #360
Draft
andystaples wants to merge 7 commits into
Draft
andystaples wants to merge 7 commits into
andystaples wants to merge 7 commits into
Conversation
andystaples
force-pushed
the
andystaples-async-stack-3-dispatch-cleanup
branch
from
November 12, 2026 16:48
fb01656 to
fe8e8bf
Compare
andystaples
force-pushed
the
andystaples-async-stack-3-dispatch-cleanup
branch
from
November 12, 2026 18:18
fe8e8bf to
466196e
Compare
Close async generators and drain or cancel pending tasks at dispatch teardown, share control-flow exception classification, and add a Windows async-runtime CI job. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
andystaples
force-pushed
the
andystaples-async-stack-3-dispatch-cleanup
branch
from
November 12, 2026 20:41
ed84f44 to
c164cb6
Compare
…async-stack-3-dispatch-cleanup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…async-stack-3-dispatch-cleanup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…async-stack-3-dispatch-cleanup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Spend each async-generator sweep's drains from the budget fixed at sweep entry, report truncation once, keep the first custom cleanup failure unless a process-control exit supersedes it, and restore the closed-loop guard. Add regression tests for these and for restoring host async-generator hooks, and document the cleanup cap prominently. Remove changelog entries for unreleased behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Do not merge this PR, or any PR in this stack, individually. The whole stack will be squash-merged only after every stack PR is approved.
Layer 3/6 of the review stack that splits the closed #293. The base is layer 2/6, #358.
Scope
Dispatch teardown for the per-dispatch durable event loop:
DurableEventLoopinstalls the async-generator hooks for each dispatch and restores the host's previous hooks afterwards.close()drains, then cancels, pending tasks and closes tracked async generators.close()is idempotent.KeyboardInterruptorSystemExittakes precedence, even when grouped or raised after other errors. The existing dispatch response is preserved, and background and cleanup errors are logged.wait_durablecannot schedule durable work once the loop is closing. The orchestration context also rejects sequence-number allocation during async cleanup, and exiting an entity critical section during teardown does not schedule extra release messages.workerinto the shareddurabletask.internal.exceptions.is_control_flow_exception. ItsBaseExceptionGrouphandling is unchanged.Docs
docs/async-orchestrators.mdgains a warning callout describing the cleanup cap and truncation, and documents async-generator ownership during dispatch, explicitaclose()/contextlib.aclosing(...), and teardown handling of entity critical sections and process-control exits.CI
Adds an
async-runtime-windowsjob to.github/workflows/durabletask.ymlthat runs the asyncio, replay, and dispatch cleanup tests on Windows across Python 3.11-3.15. Layer 4/6 (#361) extends it withtest_async_context.py.Intermediate adaptations reversed in layer 4/6
Async orchestrators still receive the eager
task.OrchestrationContextat this layer, so tests annotate contexts astask.OrchestrationContextinstead oftask.AsyncOrchestrationContext, and operations that will later go throughctx.as_task_context()(for examplecall_activity(...)andcreate_timer(...)that need eager handles) are called directly onctx.No changelog changes; release notes are added in layer 6/6 (#364).