(self, wr=None,
                 # Need to bind these locally because the globals can have
                 # been cleared at shutdown
                 _finalizer_registry=_finalizer_registry,
                 sub_debug=sub_debug, getpid=os.getpid)
Run the callback unless it has already been called or cancelled
Run the callback unless it has already been called or cancelled
Run the callback unless it has already been called or cancelled
def __call__(self, wr=None,
                 # Need to bind these locally because the globals can have
                 # been cleared at shutdown
                 _finalizer_registry=_finalizer_registry,
                 sub_debug=sub_debug, getpid=os.getpid):
        '''
        Run the callback unless it has already been called or cancelled
        '''
        try:
            del _finalizer_registry[self._key]
        except KeyError:
            sub_debug('finalizer no longer registered')
        else:
            if self._pid != getpid():
                sub_debug('finalizer ignored because different process')
                res = None
            else:
                sub_debug('finalizer calling %s with args %s and kwargs %s',
                          self._callback, self._args, self._kwargs)
                res = self._callback(*self._args, **self._kwargs)
            self._weakref = self._callback = self._args = \
                            self._kwargs = self._key = None
            return res
def __call__ ( self , wr = None , # Need to bind these locally because the globals can have # been cleared at shutdown _finalizer_registry = _finalizer_registry , sub_debug = sub_debug , getpid = os . getpid ) : try : del _finalizer_registry [ self . _key ] except KeyError : sub_debug ( 'finalizer no longer registered' ) else : if self . _pid != getpid ( ) : sub_debug ( 'finalizer ignored because different process' ) res = None else : sub_debug ( 'finalizer calling %s with args %s and kwargs %s' , self . _callback , self . _args , self . _kwargs ) res = self . _callback ( * self . _args , * * self . _kwargs ) self . _weakref = self . _callback = self . _args = self . _kwargs = self . _key = None return res