| 876 | |
| 877 | @staticmethod |
| 878 | def _decref(token, serial, authkey, state, tls, idset, _Client): |
| 879 | idset.discard(serial) |
| 880 | |
| 881 | # check whether manager is still alive |
| 882 | if state is None or state.value == State.STARTED: |
| 883 | # tell manager this process no longer cares about referent |
| 884 | try: |
| 885 | util.debug('DECREF %r', token.id) |
| 886 | conn = _Client(token.address, authkey=authkey) |
| 887 | dispatch(conn, None, 'decref', (token.id,)) |
| 888 | except Exception as e: |
| 889 | util.debug('... decref failed %s', e) |
| 890 | |
| 891 | else: |
| 892 | util.debug('DECREF %r -- manager already shutdown', token.id) |
| 893 | |
| 894 | # check whether we can close this thread's connection because |
| 895 | # the process owns no more references to objects for this manager |
| 896 | if not idset and hasattr(tls, 'connection'): |
| 897 | util.debug('thread %r has no more proxies so closing conn', |
| 898 | threading.current_thread().name) |
| 899 | tls.connection.close() |
| 900 | del tls.connection |
| 901 | |
| 902 | def _after_fork(self): |
| 903 | self._manager = None |