diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 3e8a6b75a9d..eff5d1a89c6 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -1123,10 +1123,12 @@ class _ChannelCallState(object): self.managed_calls = 0 def __del__(self): - if hasattr(self, - 'channel') and self.channel and cygrpc and cygrpc.StatusCode: + try: self.channel.close(cygrpc.StatusCode.cancelled, 'Channel deallocated!') + except (TypeError, AttributeError) as error: + logging.debug('Channel deallocation failed with: <%s>: %s', + type(error), str(error)) def _run_channel_spin_thread(state):