Uh oh!
There was an error while loading. Please reload this page.
fix(storage): ensure bidi-gRPC stream is cleaned up on open failure and close - #18119
Conversation
…nd close - Ensure socket_like_rpc is closed if open() or the initial recv() fails or is cancelled in _AsyncReadObjectStream.open() - Add _close_socket_like_rpc helper to safely handle RPC closure - Only call requests_done() in close() if socket_like_rpc is active, and ensure stream state and RPC are closed even if requests_done() fails - Add unit tests for open failures/cancellations and close behavior on inactive or failing streams
There was a problem hiding this comment.
Code Review
This pull request introduces robust exception handling and resource cleanup in _AsyncReadObjectStream during stream initialization and closure. Specifically, it wraps the bidi-gRPC stream opening and receiving logic in a try-except block to ensure the stream is closed if an error or cancellation occurs, and updates the close method to safely close the RPC connection even if signaling requests are done fails. Corresponding unit tests have been added to verify these error handling and cleanup paths. Feedback on the changes suggests consolidating the duplicate exception handling blocks for asyncio.CancelledError and Exception in the open method into a single block to reduce redundancy.
Uh oh!
There was an error while loading. Please reload this page.
…nc_read_object_stream.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes b/547471318 🦕