14 """Send multiple greeting messages to the backend."""
22 helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(
26 async
def process(stub: helloworld_pb2_grpc.GreeterStub,
27 request: helloworld_pb2.HelloRequest) ->
None:
29 response = await stub.SayHello(request)
31 print(f
'Received error: {rpc_error}')
33 print(f
'Received message: {response}')
36 async
def run(addr: str, n: int) ->
None:
37 async
with grpc.aio.insecure_channel(addr)
as channel:
45 parser = argparse.ArgumentParser()
46 parser.add_argument(
'--addr',
50 help=
'the address to request')
51 parser.add_argument(
'-n',
55 help=
'an integer for number of messages to sent')
56 args = parser.parse_args()
57 await
run(addr=args.addr, n=args.n)
60 if __name__ ==
'__main__':
61 logging.basicConfig(level=logging.INFO)
62 asyncio.get_event_loop().run_until_complete(
main())