From ecc8aa8a7130dcd31d64529e09c92626fac3c421 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 12 Jun 2020 13:07:23 -0700 Subject: [PATCH] Guard _ChannelCallState.__del__ from cygrpc being deallocated early --- src/python/grpcio/grpc/_channel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 8bae8a12127..3e8a6b75a9d 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -1123,7 +1123,8 @@ class _ChannelCallState(object): self.managed_calls = 0 def __del__(self): - if hasattr(self, 'channel') and self.channel: + if hasattr(self, + 'channel') and self.channel and cygrpc and cygrpc.StatusCode: self.channel.close(cygrpc.StatusCode.cancelled, 'Channel deallocated!')