当前位置: 首页>>代码示例>>Python>>正文


Python reactor.getDelayedCalls方法代码示例

本文整理汇总了Python中twisted.internet.reactor.getDelayedCalls方法的典型用法代码示例。如果您正苦于以下问题:Python reactor.getDelayedCalls方法的具体用法?Python reactor.getDelayedCalls怎么用?Python reactor.getDelayedCalls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.reactor的用法示例。


在下文中一共展示了reactor.getDelayedCalls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stop_reactor

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def stop_reactor():
    """Stop the reactor and join the reactor thread until it stops.
    Call this function in teardown at the module or package level to
    reset the twisted system after your tests. You *must* do this if
    you mix tests using these tools and tests using twisted.trial.
    """
    global _twisted_thread

    def stop_reactor():
        '''Helper for calling stop from withing the thread.'''
        reactor.stop()

    reactor.callFromThread(stop_reactor)
    reactor_thread.join()
    for p in reactor.getDelayedCalls():
        if p.active():
            p.cancel()
    _twisted_thread = None 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:20,代码来源:twistedtools.py

示例2: test_initiallySchedulesOneDataCall

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def test_initiallySchedulesOneDataCall(self):
        """
        When a H2Connection is established it schedules one call to be run as
        soon as the reactor has time.
        """
        reactor = task.Clock()
        a = H2Connection(reactor)

        calls = reactor.getDelayedCalls()
        self.assertEqual(len(calls), 1)
        call = calls[0]

        # Validate that the call is scheduled for right now, but hasn't run,
        # and that it's correct.
        self.assertTrue(call.active())
        self.assertEqual(call.time, 0)
        self.assertEqual(call.func, a._sendPrioritisedData)
        self.assertEqual(call.args, ())
        self.assertEqual(call.kw, {}) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_http2.py

示例3: _cleanPending

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def _cleanPending(self):
        """
        Cancel all pending calls and return their string representations.
        """
        reactor = self._getReactor()

        # flush short-range timers
        reactor.iterate(0)
        reactor.iterate(0)

        delayedCallStrings = []
        for p in reactor.getDelayedCalls():
            if p.active():
                delayedString = str(p)
                p.cancel()
            else:
                print("WEIRDNESS! pending timed call not active!")
            delayedCallStrings.append(delayedString)
        return delayedCallStrings 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:util.py

示例4: checkTimers

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def checkTimers(self):
        l1 = self.timers.values()
        l2 = list(reactor.getDelayedCalls())

        # There should be at least the calls we put in.  There may be other
        # calls that are none of our business and that we should ignore,
        # though.

        missing = []
        for dc in l1:
            if dc not in l2:
                missing.append(dc)
        if missing:
            self.finished = 1
        self.assertFalse(missing, "Should have been missing no calls, instead "
                         + "was missing " + repr(missing)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_internet.py

示例5: testGetDelayedCalls

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def testGetDelayedCalls(self):
        if not hasattr(reactor, "getDelayedCalls"):
            return
        # This is not a race because we don't do anything which might call
        # the reactor until we have all the timers set up. If we did, this
        # test might fail on slow systems.
        self.checkTimers()
        self.addTimer(35, self.done)
        self.addTimer(20, self.callback)
        self.addTimer(30, self.callback)
        which = self.counter
        self.addTimer(29, self.callback)
        self.addTimer(25, self.addCallback)
        self.addTimer(26, self.callback)

        self.timers[which].cancel()
        del self.timers[which]
        self.checkTimers()

        self.deferred.addCallback(lambda x : self.checkTimers())
        return self.deferred 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:23,代码来源:test_internet.py

示例6: _cleanPending

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def _cleanPending(self):
        """
        Cancel all pending calls and return their string representations.
        """
        reactor = self._getReactor()

        # flush short-range timers
        reactor.iterate(0)
        reactor.iterate(0)

        delayedCallStrings = []
        for p in reactor.getDelayedCalls():
            if p.active():
                delayedString = str(p)
                p.cancel()
            else:
                print "WEIRDNESS! pending timed call not active!"
            delayedCallStrings.append(delayedString)
        return delayedCallStrings 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:util.py

示例7: do_cleanPending

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def do_cleanPending(cls):
        # don't import reactor when module is loaded
        from twisted.internet import reactor

        # flush short-range timers
        reactor.iterate(0)
        reactor.iterate(0)

        pending = reactor.getDelayedCalls()
        if pending:
            s = PENDING_TIMED_CALLS_MSG
            for p in pending:
                s += " %s\n" % (p,)
                if p.active():
                    p.cancel() # delete the rest
                else:
                    print "WEIRNESS! pending timed call not active+!"
            raise PendingTimedCallsError(s) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:20,代码来源:util.py

示例8: test_noTimeoutIfConnectionLost

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def test_noTimeoutIfConnectionLost(self):
        """
        When a L{H2Connection} loses its connection it cancels its timeout.
        """
        frameFactory = FrameFactory()
        frames = buildRequestFrames(self.getRequestHeaders, [], frameFactory)
        initialData = frameFactory.clientConnectionPreface()
        initialData += b''.join(f.serialize() for f in frames)

        reactor, conn, transport = self.initiateH2Connection(
            initialData, requestFactory=DummyProducerHandler,
        )

        sentData = transport.value()
        oldCallCount = len(reactor.getDelayedCalls())

        # Now lose the connection.
        conn.connectionLost("reason")

        # There should be one fewer call than there was.
        currentCallCount = len(reactor.getDelayedCalls())
        self.assertEqual(oldCallCount - 1, currentCallCount)

        # Advancing the clock should do nothing.
        reactor.advance(101)
        self.assertEqual(transport.value(), sentData) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:28,代码来源:test_http2.py

示例9: handle_propose

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def handle_propose(self, message):
        """This method should be overridden when implementing a protocol.
            This method is always executed when the agent receives a 
            FIPA_PROPOSE type message 

            :param message: FIPA-ACL message
        """
        self.received_qty += 1
        print_progress_bar(self.received_qty, self.cfp_qty, fill='#', length=50, prefix='CFP responses received')
        if self.received_qty == self.cfp_qty:
            pass
            # delayed_calls = reactor.getDelayedCalls()
            # for call in delayed_calls:
            #     call.cancel() 
开发者ID:grei-ufc,项目名称:pade,代码行数:16,代码来源:protocols.py

示例10: handle_refuse

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def handle_refuse(self, message):
        """This method should be overridden when implementing a protocol.
            This method is always executed when the agent receives a 
            FIPA_REFUSE type message 

            :param message: FIPA-ACL message
        """
        self.received_qty += 1
        print_progress_bar(self.received_qty, self.cfp_qty, fill='#', length=50, prefix='CFP responses received')
        if self.received_qty == self.cfp_qty:
            pass
            # delayed_calls = reactor.getDelayedCalls()
            # for call in delayed_calls:
            #     call.cancel() 
开发者ID:grei-ufc,项目名称:pade,代码行数:16,代码来源:protocols.py

示例11: checkTimers

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def checkTimers(self):
        l1 = self.timers.values()
        l2 = list(reactor.getDelayedCalls())

        # There should be at least the calls we put in.  There may be other
        # calls that are none of our business and that we should ignore,
        # though.

        missing = []
        for dc in l1:
            if dc not in l2:
                missing.append(dc)
        if missing:
            self.finished = 1
        self.failIf(missing, "Should have been missing no calls, instead was missing " + repr(missing)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:17,代码来源:test_internet.py

示例12: setUp

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def setUp(self):
        self.finished = 0
        self.counter = 0
        self.timers = {}
        self.deferred = defer.Deferred()
        # ick. Sometimes there are magic timers already running:
        # popsicle.Freezer.tick . Kill off all such timers now so they won't
        # interfere with the test. Of course, this kind of requires that
        # getDelayedCalls already works, so certain failure modes won't be
        # noticed.
        if not hasattr(reactor, "getDelayedCalls"):
            return
        for t in reactor.getDelayedCalls():
            t.cancel()
        reactor.iterate() # flush timers 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:17,代码来源:test_internet.py

示例13: setup_cj

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def setup_cj():
    load_test_config()
    jm_single().config.set('POLICY', 'tx_broadcast', 'self')
    jm_single().bc_interface.tick_forward_chain_interval = 5
    jm_single().bc_interface.simulate_blocks()
    #see note in cryptoengine.py:
    cryptoengine.BTC_P2WPKH.VBYTE = 100
    yield None
    # teardown
    for dc in reactor.getDelayedCalls():
        dc.cancel() 
开发者ID:JoinMarket-Org,项目名称:joinmarket-clientserver,代码行数:13,代码来源:test_payjoin.py

示例14: setup_taker

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def setup_taker(request):
    def clean():
        from twisted.internet import reactor
        for dc in reactor.getDelayedCalls():
            dc.cancel()
    request.addfinalizer(clean)
    def cmtdatateardown():
        shutil.rmtree("cmtdata")
    request.addfinalizer(cmtdatateardown)
    if not os.path.exists("cmtdata"):
            os.makedirs("cmtdata")
    load_test_config()
    jm_single().bc_interface = DummyBlockchainInterface()
    jm_single().config.set("BLOCKCHAIN", "network", "testnet") 
开发者ID:JoinMarket-Org,项目名称:joinmarket-clientserver,代码行数:16,代码来源:test_taker.py

示例15: tearDown

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import getDelayedCalls [as 别名]
def tearDown(self):
        for dc in reactor.getDelayedCalls():
            dc.cancel() 
开发者ID:JoinMarket-Org,项目名称:joinmarket-clientserver,代码行数:5,代码来源:test_client_protocol.py


注:本文中的twisted.internet.reactor.getDelayedCalls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。