Repository navigation
feat: capture cancelled model calls - #2794
Merged
cmunley1 merged 4 commits intoSep 3, 2026
Merged
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Elisa Martinez Abad <[email protected]>
elisam0
force-pushed
the
elisam0/capture-cancelled-model-calls
branch
from
August 26, 2026 15:22
1b88ab0 to
550139a
Compare
elisam0
marked this pull request as ready for review
August 26, 2026 15:23
Contributor
Author
|
/claude review |
Contributor
|
SHIP — LGTM, no reliability concerns. The change makes
|
Contributor
|
/ok to test 609b06f |
cmunley1
approved these changes
Sep 3, 2026
Contributor
|
the await asyncio.to_thread(_record, ...) in the cancel handler is itself cancellable, so a second cancellation (server shutdown, an enclosing asyncio.timeout) drops the record we're trying to save. Do you think we should wrap in asyncio.shield or just call _record sync here? |
jkyi-nvidia
pushed a commit
that referenced
this pull request
Sep 11, 2026
## What does this PR do? Captures model-call records when a client disconnects or cancels an in-flight request handled by `ModelServerCaptureMiddleware`. Before this change, the middleware only recorded failures caught by `except Exception`. On Python 3.8+, `asyncio.CancelledError` inherits from `BaseException`, so cancellations raised by the ASGI layer bypassed the capture path entirely. The result was that client-side timeout/cancellation events could be missing from `model_calls/*.capture.jsonl`, making a cancelled request look indistinguishable from a request that never happened. This PR updates the middleware to catch `asyncio.CancelledError` alongside normal exceptions, classify it as `error_category: "cancelled"`, write the capture record, and then re-raise so cancellation semantics are preserved. It also adds unit coverage that externally cancels an in-flight middleware task and verifies that the raw capture store contains a cancelled record with no response or status code. ## Checklist - [x] I have read the [contributing guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format/copyright pass). - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). Signed-off-by: Elisa Martinez Abad <[email protected]> Co-authored-by: Christian Munley <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
This was referenced Oct 1, 2026
This branch was previously 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.
What does this PR do?
Captures model-call records when a client disconnects or cancels an in-flight request handled by
ModelServerCaptureMiddleware.Before this change, the middleware only recorded failures caught by
except Exception. On Python 3.8+,asyncio.CancelledErrorinherits fromBaseException, so cancellations raised by the ASGI layer bypassed thecapture path entirely. The result was that client-side timeout/cancellation events could be missing from
model_calls/*.capture.jsonl, making a cancelled request look indistinguishable from a request that never happened.This PR updates the middleware to catch
asyncio.CancelledErroralongside normal exceptions, classify it aserror_category: "cancelled", write the capture record, and then re-raise so cancellation semantics are preserved.It also adds unit coverage that externally cancels an in-flight middleware task and verifies that the raw capture store
contains a cancelled record with no response or status code.
Checklist
pre-commit run --all-files) (so CI lint/format/copyright pass).git commit -s) (so the DCO check passes).