コード例 #1
0
ファイル: pb.py プロジェクト: pexip/os-foolscap
    def setup(self, options):
        self.options = options
        self.logger = flog.theLogger
        self.listeners = []
        self.locationHints = []

        # duplicate-connection management
        self.make_incarnation()

        # the master_table records the master-seqnum we used for the last
        # established connection with the given tubid. It only contains
        # entries for which we were the master.
        self.master_table = {}  # k:tubid, v:seqnum
        # the slave_table records the (master-IR,master-seqnum) pair for the
        # last established connection with the given tubid. It only contains
        # entries for which we were the slave.
        self.slave_table = {}  # k:tubid, v:(master-IR,seqnum)

        # local Referenceables
        self.nameToReference = weakref.WeakValueDictionary()
        self.referenceToName = weakref.WeakKeyDictionary()
        self.strongReferences = []
        self.nameLookupHandlers = []

        # remote stuff. Most of these use a TubRef (or NoAuthTubRef) as a
        # dictionary key
        self.tubConnectors = {}  # maps TubRef to a TubConnector
        self.waitingForBrokers = {}  # maps TubRef to list of Deferreds
        self.brokers = {}  # maps TubRef to a Broker that connects to them
        self.unauthenticatedBrokers = []  # inbound Brokers without TubRefs
        self.reconnectors = []

        # all connections, used or not, go in here, so we can stall
        # stopService() until they're all gone.
        self._allConnections = set()
        self._allConnectionsAreDisconnected = observer.OneShotObserverList()

        self._activeConnectors = []
        self._allConnectorsAreFinished = observer.OneShotObserverList()

        self._pending_getReferences = []  # list of (d, furl) pairs

        self._logport = None
        self._logport_furl = None
        self._logport_furlfile = None

        self._log_gatherer_furls = []
        self._log_gatherer_furlfile = None
        self._log_gatherer_connectors = {}  # maps furl to reconnector

        self._handle_old_duplicate_connections = False
        self._expose_remote_exception_types = True
コード例 #2
0
ファイル: test_observer.py プロジェクト: sajith/foolscap
    def test_oneshot(self):
        ol = observer.OneShotObserverList()
        rep = repr(ol)
        d1 = ol.whenFired()
        d2 = ol.whenFired()

        def _addmore(res):
            self.assertEqual(res, "result")
            d3 = ol.whenFired()
            d3.addCallback(self.assertEqual, "result")
            return d3

        d1.addCallback(_addmore)
        ol.fire("result")
        rep = repr(ol)
        del rep
        d4 = ol.whenFired()
        dl = defer.DeferredList([d1, d2, d4])
        return dl