aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/grpc/_interceptor.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio/grpc/_interceptor.py')
-rw-r--r--src/python/grpcio/grpc/_interceptor.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/python/grpcio/grpc/_interceptor.py b/src/python/grpcio/grpc/_interceptor.py
index d029472c68..f465e35a9c 100644
--- a/src/python/grpcio/grpc/_interceptor.py
+++ b/src/python/grpcio/grpc/_interceptor.py
@@ -334,6 +334,19 @@ class _Channel(grpc.Channel):
else:
return thunk(method)
+ def _close(self):
+ self._channel.close()
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self._close()
+ return False
+
+ def close(self):
+ self._channel.close()
+
def intercept_channel(channel, *interceptors):
for interceptor in reversed(list(interceptors)):