Add python async example for hellostreamingworld using generator#27343
Conversation
|
|
|
@lidizheng this example looks great to me! definately something I would have liked to have when I was exploring the examples for the first time. |
|
I guess we already have a more complicated async streaming example: https://github.com/grpc/grpc/tree/master/examples/python/async_streaming and all the other helloworld async tests are in a different directory: https://github.com/grpc/grpc/tree/master/examples/python/helloworld |
lidizheng
left a comment
There was a problem hiding this comment.
Thanks! This example looks great. Just have some style comments.
| self, request: HelloRequest, | ||
| context: grpc.aio.ServicerContext) -> HelloReply: | ||
| logging.info(f"Serving sayHello request {request}") | ||
| async for msg in say_hello_generator(request): |
There was a problem hiding this comment.
I would recommend to simplify port the message generation here.
There was a problem hiding this comment.
I've kept it that way to show how you can integrate with external generator (this was my first use case for this example)
There was a problem hiding this comment.
I see what you are proposing. This example file focuses on how to write a streaming gRPC server handler. Using an extra layer of generator doesn't seem to yield more helpful info for readers.
lidizheng
left a comment
There was a problem hiding this comment.
Looks great. Can you check the result of the Sanity Tests?
| self, request: HelloRequest, | ||
| context: grpc.aio.ServicerContext) -> HelloReply: | ||
| logging.info(f"Serving sayHello request {request}") | ||
| async for msg in say_hello_generator(request): |
There was a problem hiding this comment.
I see what you are proposing. This example file focuses on how to write a streaming gRPC server handler. Using an extra layer of generator doesn't seem to yield more helpful info for readers.
|
This issue/PR has been automatically marked as stale because it has not had any update (including commits, comments, labels, milestones, etc) for 30 days. It will be closed automatically if no further update occurs in 7 day. Thank you for your contributions! |
|
Just waiting for a review. Anyone available? |
|
@mickours The sanity checks can be fixed by running: You can also check for pylint errors locally: |
|
I've apply the auto-format and lint scripts. Should be OK now. |
|
Known failure: #28483 |
Following of the issue #24603 .
The problem was a missing example not a bug in the gRPC implementation, so here is an example of async Unary Stream call using the already present
hellostreamingworld.protodefinition.It uses a message async generator out of the object to provide an example for that kind of usage.
@yashykt