def connectionLost(self, reason): """The connection was lost. """ self.disconnected = 1 # nuke potential circular references. self.luids = None if self.waitingForAnswers: for d in self.waitingForAnswers.values(): try: d.errback(failure.Failure(PBConnectionLost(reason))) except: log.deferr() # Assure all Cacheable.stoppedObserving are called for lobj in self.remotelyCachedObjects.values(): cacheable = lobj.object perspective = lobj.perspective try: cacheable.stoppedObserving(perspective, RemoteCacheObserver(self, cacheable, perspective)) except: log.deferr() # Loop on a copy to prevent notifiers to mixup # the list by calling dontNotifyOnDisconnect for notifier in self.disconnects[:]: try: notifier() except: log.deferr() self.disconnects = None self.waitingForAnswers = None self.localSecurity = None self.remoteSecurity = None self.remotelyCachedObjects = None self.remotelyCachedLUIDs = None self.locallyCachedObjects = None self.localObjects = None
def proto_decache(self, objectID): """(internal) Decrement the reference count of a cached object. If the reference count is zero, free the reference, then send an 'uncached' directive. """ refs = self.remotelyCachedObjects[objectID].decref() # log.msg('decaching: %s #refs: %s' % (objectID, refs)) if refs == 0: lobj = self.remotelyCachedObjects[objectID] cacheable = lobj.object perspective = lobj.perspective # TODO: force_decache needs to be able to force-invalidate a # cacheable reference. try: cacheable.stoppedObserving(perspective, RemoteCacheObserver(self, cacheable, perspective)) except: log.deferr() puid = cacheable.processUniqueID() del self.remotelyCachedLUIDs[puid] del self.remotelyCachedObjects[objectID] self.sendCall("uncache", objectID)