Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

daniel-sanche
Copy link
Contributor

We recently made a change to move some computation in the async rpc wrapper from call-time to wrap-time. This way, individual calls would execute faster, since they don't have to re-compute some data on each call

A side-effect of this change is that now some type validation happens earlier. This caused some downstream tests to fail when a mock grpc channel is used. The wrapper doesn't know how to handle the mock.Mock type, and raises an exception while constructing the client object

This PR fixes the issue by falling back to the unary wrapper when the callable type is unknown, rather than raising an exception. This is in-line with how the sync version handles it

We recently [made a change](ab22afd) to move some computation in the async rpc wrapper from call-time to wrap-time. This way, individual calls would execute faster, since they don't have to re-compute some data on each call

A side-effect of this change is that now some [type validation](https://github.com/googleapis/python-api-core/blob/d96eb5cdd8120bfec97d62b09512c6fecc325be8/google/api_core/grpc_helpers_async.py#L209) happens earlier. This caused some downstream tests to fail when a mock grpc channel is used. The wrapper doesn't know how to handle the mock.Mock type, and raises an exception while constructing the client object

This PR fixes the issue by falling back to the unary wrapper when the callable type is unknown, rather than raising an exception. This is in-line with how [the sync version handles it](https://github.com/googleapis/python-api-core/blob/d96eb5cdd8120bfec97d62b09512c6fecc325be8/google/api_core/grpc_helpers.py#L198)
@daniel-sanche daniel-sanche requested review from a team as code owners May 9, 2024 20:43
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label May 9, 2024
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels May 9, 2024
@parthea parthea changed the title fix: fallback to unary_unary when wrapping async callables chore: fallback to unary_unary when wrapping async callables Jun 4, 2024
@parthea parthea merged commit c9e1cbb into main Jun 4, 2024
@parthea parthea deleted the fall-back-to-unary branch June 4, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants