-
Notifications
You must be signed in to change notification settings - Fork 169
fix: update write handle on every recv() #1716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @chandra-siri, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the robustness and correctness of asynchronous object writing and reading operations, particularly concerning the management of Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a fix to update the write_handle on every recv() call, ensuring the most current handle is used. This is achieved by adding a new utility function and applying it across different stream operations. The changes also include updating type hints for handles from bytes to their specific proto types, which improves code clarity and correctness. Additionally, there's a significant and valuable refactoring of the system tests to use session-scoped event loops and gRPC clients, which should improve test performance and stability. I've identified one critical bug in async_write_object_stream.py where an AttributeError could occur when opening a stream with an existing write_handle. A code suggestion to fix this is provided.
I am having trouble creating individual review comments. Click here to see my feedback.
google/cloud/storage/_experimental/asyncio/async_write_object_stream.py (153-181)
When opening a stream with is_open_via_write_handle=True, response.resource is not guaranteed to be populated. Accessing response.resource.generation will raise an AttributeError. The generation number is already known in this case, so it should only be updated from the response when a new stream is created without a handle.
self.generation_number = response.resource.generation should be moved inside the else block that handles the case where is_open_via_write_handle is false.
if is_open_via_write_handle:
# Don't use if not response.persisted_size because this will be true
# if persisted_size==0 (0 is considered "Falsy" in Python)
if response.persisted_size is None:
raise ValueError(
"Failed to obtain persisted_size after opening the stream via write_handle"
)
self.persisted_size = response.persisted_size
else:
if not response.resource:
raise ValueError(
"Failed to obtain object resource after opening the stream"
)
if not response.resource.generation:
raise ValueError(
"Failed to obtain object generation after opening the stream"
)
if not response.resource.size:
# Appending to a 0 byte appendable object.
self.persisted_size = 0
else:
self.persisted_size = response.resource.size
self.generation_number = response.resource.generation
if not response.write_handle:
raise ValueError("Failed to obtain write_handle after opening the stream")
self.write_handle = response.write_handleThe merge-base changed after approval.
fix: update
write_handleon everyrecv()from write object stream.