aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/python/route_guide
diff options
context:
space:
mode:
authorGravatar Nathaniel Manista <nathaniel@google.com>2018-06-12 17:30:23 +0000
committerGravatar Nathaniel Manista <nathaniel@google.com>2018-06-14 17:16:04 +0000
commit8234d14113f484c60ee8633dc060f8054adf3748 (patch)
tree115e9e3d56178687028127a7d2dd457608e3ad54 /examples/python/route_guide
parenta70053690a3f07ecf69ff283c288d018d2362ee4 (diff)
Close channels in examples
Diffstat (limited to 'examples/python/route_guide')
-rw-r--r--examples/python/route_guide/route_guide_client.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/examples/python/route_guide/route_guide_client.py b/examples/python/route_guide/route_guide_client.py
index f2d4317ef1..b4ff3239ba 100644
--- a/examples/python/route_guide/route_guide_client.py
+++ b/examples/python/route_guide/route_guide_client.py
@@ -100,16 +100,19 @@ def guide_route_chat(stub):
def run():
- channel = grpc.insecure_channel('localhost:50051')
- stub = route_guide_pb2_grpc.RouteGuideStub(channel)
- print("-------------- GetFeature --------------")
- guide_get_feature(stub)
- print("-------------- ListFeatures --------------")
- guide_list_features(stub)
- print("-------------- RecordRoute --------------")
- guide_record_route(stub)
- print("-------------- RouteChat --------------")
- guide_route_chat(stub)
+ # 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 = route_guide_pb2_grpc.RouteGuideStub(channel)
+ print("-------------- GetFeature --------------")
+ guide_get_feature(stub)
+ print("-------------- ListFeatures --------------")
+ guide_list_features(stub)
+ print("-------------- RecordRoute --------------")
+ guide_record_route(stub)
+ print("-------------- RouteChat --------------")
+ guide_route_chat(stub)
if __name__ == '__main__':