Repository navigation
fix: drain request disconnect tasks on cancellation - #528
Open
cloudgpuapp wants to merge 1 commit into
Open
cloudgpuapp wants to merge 1 commit into
cloudgpuapp wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Is your pull request related to a problem? Please describe.
run_with_request_disconnect()waits for the supplied task or a disconnect watcher. If its own caller is cancelled during that wait, it exits without cancelling either child. Its normal/error/disconnect paths also request cancellation without awaiting child cleanup.The helper is used by embeddings, embedding-model loading and model downloads. This change does not modify the streaming chat/completions path or claim to fix #502.
Why should this feature be added?
Keep explicit references to both tasks and cancel/drain them in
finally, including when the outer request task is cancelled. Preserve the existing result, call exception and HTTP 422 behavior. Outer task cancellation continues to propagate asCancelledError.Examples
The regression test starts both tasks behind Events, cancels the wrapper and checks that both children have finished their asynchronous cleanup before it exits. Another case holds a child's cleanup behind an Event, verifies the wrapper is still pending, then releases it in
finallyso no test task is left behind.Additional context
common.networkingand its configuration/logger dependencies. The work and disconnect coroutines are controlled test doubles; no AST extraction, native backend stub, model, network download or GPU workload.port_bind_error. Full model/server tests were not run.Prepared with AI assistance; no provider integration or promotional links are added.