Repository navigation
Conversation
Chain premature-close errors from recorded reader failures so bundle errors retain the original cause and omit unrelated queue timeouts. Fixes apache#40774. Generated-by: OpenAI Codex (GPT-6) AI-Model: gpt-6 AI-Contributed/Feature: 3/3 AI-Contributed/UT: 50/50
There was a problem hiding this comment.
📋 Review Summary
This PR preserves the underlying data-plane exception as the explicit __cause__ when _GrpcDataChannel.input_elements raises RuntimeError('Channel closed prematurely.'), improving error diagnostics while suppressing the noisy queue.Empty context when no exception was recorded. The implementation is minimal, backwards-compatible, and well-covered by new unit tests.
🔍 General Feedback
- Chaining
from self._exceptioncleanly addresses the race/ordering betweenself._closedandself._exceptionin_read_inputswithout altering existing exception types or abort semantics. - Consider mocking or shortening the queue poll timeout in the new unit tests, as 3 of the 4 added tests each wait on the hardcoded
received.get(timeout=1)call (~3 seconds total).
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Inject queue.Empty in the three timeout-driven tests instead of waiting for each one-second queue poll. Keep the real reader and consumer paths and their diagnostic assertions intact. Generated-by: OpenAI Codex (GPT-6) AI-Model: gpt-6 AI-Contributed/Feature: 0/0 AI-Contributed/UT: 11/11
Register the expected close failure with addCleanup and retain the consumer cause assertion, removing redundant reader and close checks. Generated-by: OpenAI Codex (gpt-6-astra) AI-Model: gpt-6-astra AI-Contributed/Feature: 0/0 AI-Contributed/UT: 27/27
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Fixes #40774.
When a data channel closes after a read failure,
input_elementshides the saved exception. Chain it as the cause ofChannel closed prematurely; suppress the unrelatedqueue.Emptycontext when no cause exists.Tests cover reader failure, premature EOF, normal completion and cancellation. All 9 data-plane tests pass; the two diagnostic regressions fail without the fix. Ruff and YAPF pass.
AI assistance: OpenAI Codex.