hrpc/example/client.py
Luke Murphy 1f61e86cba
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Clean up example
2020-08-09 03:53:39 +02:00

26 lines
594 B
Python

"""Greeter client."""
import anyio
import purerpc
from greeter_grpc import GreeterStub
from greeter_pb2 import HelloReply, HelloRequest
async def gen():
for i in range(5):
yield HelloRequest(name=str(i))
async def main():
async with purerpc.insecure_channel("localhost", 50055) as channel:
stub = GreeterStub(channel)
reply = await stub.SayHello(HelloRequest(name="World"))
print(reply.message)
async for reply in stub.SayHelloToMany(gen()):
print(reply.message)
if __name__ == "__main__":
anyio.run(main, backend="trio")