Merge pull request #17008 from stub42/yay_destructors

Handle missing globals in Python Channel destructors
pull/16976/head
Lidi Zheng 6 years ago committed by GitHub
commit f091ba1b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/python/grpcio/grpc/_channel.py

@ -980,8 +980,9 @@ class Channel(grpc.Channel):
# for as long as they are in use and to close them after using them,
# then deletion of this grpc._channel.Channel instance can be made to
# effect closure of the underlying cygrpc.Channel instance.
cygrpc.fork_unregister_channel(self)
if cygrpc is not None: # Globals may have already been collected.
cygrpc.fork_unregister_channel(self)
# This prevent the failed-at-initializing object removal from failing.
# Though the __init__ failed, the removal will still trigger __del__.
if hasattr(self, "_connectivity_state"):
if _moot is not None and hasattr(self, "_connectivity_state"):
_moot(self._connectivity_state)

Loading…
Cancel
Save