From 8234d14113f484c60ee8633dc060f8054adf3748 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Tue, 12 Jun 2018 17:30:23 +0000 Subject: Close channels in examples --- examples/python/helloworld/greeter_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'examples/python/helloworld/greeter_client.py') diff --git a/examples/python/helloworld/greeter_client.py b/examples/python/helloworld/greeter_client.py index a0aeb47bd7..24b49ac233 100644 --- a/examples/python/helloworld/greeter_client.py +++ b/examples/python/helloworld/greeter_client.py @@ -22,9 +22,12 @@ import helloworld_pb2_grpc def run(): - channel = grpc.insecure_channel('localhost:50051') - stub = helloworld_pb2_grpc.GreeterStub(channel) - response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) + # 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. + with grpc.insecure_channel('localhost:50051') as channel: + stub = helloworld_pb2_grpc.GreeterStub(channel) + response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) print("Greeter client received: " + response.message) -- cgit v1.2.3