-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Python AIO] Return EOF from UnaryStreamCall.read() as documented #36660
Conversation
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.
Looks great! Thanks for the fix
@@ -223,6 +223,50 @@ async def test_response_iterator_using_read(self): | |||
|
|||
await channel.close() | |||
|
|||
async def test_too_many_reads(self): | |||
for interceptor_class in ( | |||
_UnaryStreamInterceptorEmpty, |
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.
I like the use of the subtest with the loop. It would be nice if we could also have a subtest that didn't include an interceptor at all. Running the exact same test against both an interceptor and a channel without an interceptor would help reinforce our principle that it should not be possible to tell whether a channel has an interceptor enabled or not externally.
I think you can change this by changing the iterable you're iterating over from Tuple[Callable[[], Interceptor]]
to Tuple[List[Callable[[], Interceptor]]]
, and using []
to represent the variant with no interceptors.
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.
Good idea, I'll add a subtest for channel without interceptor as well.
CC @sourabhsinghs for visibility |
Fix: #36581
Based on our documentation, we should return
grpc.aio.EOF
to indicate the end of the stream:grpc/src/python/grpcio/grpc/aio/_base_call.py
Lines 166 to 178 in fb6a57b
But if the call was intercepted, we're raising
StopAsyncIteration
, This Pr changes the return to match the documentation (Which is also the behavior for non-intercepted call).