From 166824205ea46979b0a7478135342a6c63879969 Mon Sep 17 00:00:00 2001 From: AmosWang Date: Wed, 14 Sep 2022 15:54:01 -0700 Subject: [PATCH] Print info when server starts (#30964) --- examples/python/helloworld/greeter_client.py | 1 + examples/python/helloworld/greeter_server.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/python/helloworld/greeter_client.py b/examples/python/helloworld/greeter_client.py index afab3999314..fc8f1b09053 100644 --- a/examples/python/helloworld/greeter_client.py +++ b/examples/python/helloworld/greeter_client.py @@ -26,6 +26,7 @@ def run(): # NOTE(gRPC Python Team): .close() is possible on a channel and should be # used in circumstances in which the with statement does not fit the needs # of the code. + print("Will try to greet world ...") with grpc.insecure_channel('localhost:50051') as channel: stub = helloworld_pb2_grpc.GreeterStub(channel) response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py index acc5adbfe15..04a0e50efa2 100644 --- a/examples/python/helloworld/greeter_server.py +++ b/examples/python/helloworld/greeter_server.py @@ -28,10 +28,12 @@ class Greeter(helloworld_pb2_grpc.GreeterServicer): def serve(): + port = '50051' server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) - server.add_insecure_port('[::]:50051') + server.add_insecure_port('[::]:' + port) server.start() + print("Server started, listening on " + port) server.wait_for_termination()