• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python reactor.getDelayedCalls函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_cleanReactor_delayed_calls_all_active

    def test_cleanReactor_delayed_calls_all_active(self):
        """
        It will cancel any delayed calls in the reactor queue.
        """
        reactor.callLater(1, self.ignoreFailure)
        reactor.callLater(2, self.ignoreFailure)
        self.assertIsNotEmpty(reactor.getDelayedCalls())

        self._cleanReactor()

        self.assertIsEmpty(reactor.getDelayedCalls())
开发者ID:chevah,项目名称:compat,代码行数:11,代码来源:test_testcase.py


示例2: test_delayedCallCleanup

    def test_delayedCallCleanup(self):
        """Checking to make sure Sessions do not leave extra DelayedCalls.
        """
        from twisted.internet import reactor

        delayedCallsBeforeSession = repr(reactor.getDelayedCalls())

        session = self.site.makeSession()
        session.touch()
        session.expire()

        self.failUnlessEqual(delayedCallsBeforeSession, repr(reactor.getDelayedCalls()))
开发者ID:mrader11,项目名称:vodafone-mobile-connect,代码行数:12,代码来源:test_web.py


示例3: umount

    def umount(self):
        self.readonly = True
        if self.shutting_down:
            trace("shutdown", "called twice")
            return
        try:
            self.shutting_down = True

            trace("shutdown", "stopping services")
            yield self.services.stopService()
            trace("shutdown", "disconnect peers")
            self.disconnect_all()
            for k in self.remote.keys():
                del self.remote[k]
            n = 0
            for c in reactor.getDelayedCalls():
                n += 1
                trace("shutdown", "speed-up %s", c)
                c.reset(0)
            if n:
                trace("shutdown", "speed-up wait %d", n)
                yield reactor.callLater(n / 10, lambda: None)
            trace("shutdown", "run idle")
            yield IdleWorker.run()
            trace("shutdown", "flush inodes")
            yield self.db(flush_inodes)
            trace("shutdown", "super")
            yield super(SqlFuse, self).stop(False)
            trace("shutdown", "stop DB")
            yield self.db.stopService()
            trace("shutdown", "done")
        except Exception as e:
            log.err(e, "Shutting down")
            traceback.print_exc()
开发者ID:arielsalvo,项目名称:sqlfuse,代码行数:34,代码来源:main.py


示例4: shutdown

def shutdown():
    global main_xmlrpc_handler
    global _xmlrpc_listener
    global _xmlrpc_site
    try:
        site = _xmlrpc_site
        logging.info("shutting down, first closing listening ports...")
        print("Shutting down, hold on a moment...")
        yield stop_listening()

# This doesn't work, site.session is always empty
        logging.info("Ports closed, waiting for current sessions to close...")
        logging.debug("Clients still connected: {}".format(len(site.sessions)))
        while not len(site.sessions)==0:
            logging.debug("Waiting, {} sessions still active".format(len(site.sessions)))
            yield task.deferLater(reactor, 1, lambda _:0, 0)

        logging.info("No more sessions, waiting for locked hosts...")
        while not utils.none_waiting():
            logging.info("Waiting to shut down, {} hosts still blocked".format(utils.count_waiting()))
            yield task.deferLater(reactor, 1, lambda _:0, 0)
            logging.debug("reactor.getDelayedCalls: {}".format([c.func for c in reactor.getDelayedCalls()]))

        logging.info("All hosts unlocked, waiting 3 more seconds...")
        yield task.deferLater(reactor, 1, lambda _:0, 0)
        logging.debug("Waiting 2 more seconds...")
        yield task.deferLater(reactor, 1, lambda _:0, 0)
        logging.debug("Waiting 1 more second...")
        yield task.deferLater(reactor, 1, lambda _:0, 0)
        logging.info("Continuing shutdown")
    except:
        logging.exception("Error in shutdown callback")
开发者ID:janpascal,项目名称:denyhosts_sync,代码行数:32,代码来源:main.py


示例5: check_clean

def check_clean(_):
    delayed_calls = reactor.getDelayedCalls()
    if delayed_calls:
        print "DIRTY"
    else:
        print "CLEAN"
    reactor.stop()
开发者ID:lfdversluis,项目名称:python-stuff,代码行数:7,代码来源:shutdown_ex.py


示例6: tearDown

 def tearDown(self):
     super(DNSQueryMonitoringProtocolTestCase, self).tearDown()
     # There doesn't seem to be any sane way to avoid the delayed call to
     # maybeParseConfig: https://twistedmatrix.com/trac/ticket/3745
     for call in reactor.getDelayedCalls():
         if call.func.func_name == 'maybeParseConfig':
             call.cancel()
开发者ID:wikimedia,项目名称:PyBal,代码行数:7,代码来源:test_dnsquery.py


示例7: runtime_info

def runtime_info():
    delayed = reactor.getDelayedCalls()
    readers = reactor.getReaders()
    writers = reactor.getWriters()
    servers = []
    clients = []
    other = []
    for reader in readers:
        if isinstance(reader, tcp.Server):
            servers.append({
                'transport': reader,
                'host': reader.getHost(),
                'peer': reader.getPeer()
            })
        elif isinstance(reader, tcp.Client):
            clients.append({
                'transport': reader,
                'host': reader.getHost(),
                'peer': reader.getPeer()
            })
        else:
            other.append(reader)
    return {
        'num_clients': len(clients),
        'num_servers': len(servers),
        'num_other': len(other),
        'num_writers': len(writers),
        'num_delayed': len(delayed),
        'clients': clients,
        'servers': servers,
        'other': other,
        'writers': writers,
        'delayed': delayed,
    }
开发者ID:Libreno,项目名称:swftp,代码行数:34,代码来源:utils.py


示例8: print_runtime_info

def print_runtime_info(sig, frame):
    if sig in [signal.SIGUSR1, signal.SIGUSR2]:
        delayed = reactor.getDelayedCalls()
        readers = reactor.getReaders()
        writers = reactor.getWriters()
        clients = []
        http_conn_num = 0
        for reader in readers:
            if isinstance(reader, twisted.internet.tcp.Server):
                clients.append(reader.getPeer())
            if isinstance(reader, twisted.internet.tcp.Client):
                http_conn_num += 1
        log.msg(
            "[Clients: %(client_num)s] [HTTP Conns: %(http_conn_num)s] "
            "[Readers: %(reader_num)s] [Writers: %(writer_num)s] "
            "[DelayedCalls: %(delayed_num)s]"
            % {
                "client_num": len(clients),
                "http_conn_num": http_conn_num,
                "reader_num": len(readers),
                "writer_num": len(writers),
                "delayed_num": len(delayed),
            }
        )
        log.msg("[Connected Clients]: %s" % clients)
        if sig == signal.SIGUSR2:
            for d in delayed:
                log.msg("SIGUSR2[delayed]: %s" % d)

            for r in readers:
                log.msg("SIGUSR2[reader]: %s" % r)

            for w in writers:
                log.msg("SIGUSR2[writer]: %s" % w)
开发者ID:smerritt,项目名称:swftp,代码行数:34,代码来源:utils.py


示例9: testQuestionLoadSpeed

    def testQuestionLoadSpeed(self):
        "Check if trivia questions load fast enough."

        session = self.trivia_plugin.Session()

        #Create questions
        for i in range(40000): #There can be a lot of trivia questions
            question_string = generate_random_sentence(5, 10, 5, 20)
            answer_string = generate_random_sentence(1, 6, 1, 20)
            category_string = generate_random_word(10, 30)
            question = RegularQuestion(question = question_string, answer = answer_string, category = category_string)
            session.save_or_update(question)
        session.commit()

        #Load questions and check the amount of time it takes
        questions_asked = 5000
        before = datetime.now()
        for i in range(questions_asked):
            self.trivia_plugin.on_next_question(self.vtkbot, self.channel)
            timers = reactor.getDelayedCalls()
            for timer in timers:
                try:
                    timer.cancel()
                except:
                    pass
        after = datetime.now()
        diff = after - before
        self.assert_(diff.seconds < questions_asked/20) #Questions need to be asked as fast as possible, to avoid long delays for the trivia players
开发者ID:B-Rich,项目名称:VTKBot,代码行数:28,代码来源:tests.py


示例10: tearDown

 def tearDown(self):
     """!Tear down a test
     """
     delayedCalls = reactor.getDelayedCalls()
     for call in delayedCalls:
         call.cancel()
     return self.dw.close()
开发者ID:csayres,项目名称:lcoTCC,代码行数:7,代码来源:testLCOCommands.py


示例11: checkSessionCreated

 def checkSessionCreated(request):
     cookie = request.getCookie(fresources.COOKIE_NAME)
     self.failIf(cookie is None)
     sessionID = base64.b64decode(cookie).split(':')[0]
     session = self.site.sessions.get(sessionID, None)
     self.failIf(session is None)
     for d in reactor.getDelayedCalls():
         d.cancel()
开发者ID:ApsOps,项目名称:flumotion-orig,代码行数:8,代码来源:test_hls_resource.py


示例12: tearDown

 def tearDown(self):
     yield self.client.remove('test', CF)
     yield self.client.remove('test2', CF)
     yield self.client.remove('test', SCF)
     yield self.client.remove('test2', SCF)
     self.cmanager.shutdown()
     for c in reactor.getDelayedCalls():
         c.cancel()
     reactor.removeAll()
开发者ID:ericflo,项目名称:Telephus,代码行数:9,代码来源:test_cassandraclient.py


示例13: _reactorQueueToString

 def _reactorQueueToString(self):
     """
     Return a string representation of all delayed calls from reactor
     queue.
     """
     result = []
     for delayed in reactor.getDelayedCalls():
         result.append(str(delayed.func))
     return '\n'.join(result)
开发者ID:chevah,项目名称:empirical,代码行数:9,代码来源:testcase.py


示例14: tearDown

 def tearDown(self):
     pending = reactor.getDelayedCalls()
     active = bool(pending)
     for p in pending:
         print p
         if p.active():
             print "cancel"
             p.cancel()
     print "fini"
开发者ID:dynamikdev,项目名称:txredisTools,代码行数:9,代码来源:test.py


示例15: _delayed_calls_done

 def _delayed_calls_done(self):
     # We're done when the only remaining DelayedCalls fire after threshold.
     # (These will be associated with the test timeout, or else they *should*
     # cause an unclean reactor error because the test should have waited for
     # them.)
     threshold = time.time() + 10
     for delayed in reactor.getDelayedCalls():
         if delayed.getTime() < threshold:
             return False
     return True
开发者ID:warner,项目名称:tahoe-lafs,代码行数:10,代码来源:deferredutil.py


示例16: clean_reactor

def clean_reactor():
    """
    Cleans the reactor of any uncalled DelayedCall objects created by
    reactor.callLater().  This is useful for tests that run without the reactor
    and do not actually need the DelayedCall to run.
    """
    
    # clean reactor
    for call in reactor.getDelayedCalls():
        call.cancel()
开发者ID:MostAwesomeDude,项目名称:pydra,代码行数:10,代码来源:__init__.py


示例17: checkSessionID

 def checkSessionID(request):
     # The auth is not valid anymore and has been renewed,
     # but the session should stay the same
     cookie = request.getCookie(fresources.COOKIE_NAME)
     self.failIf(cookie is None)
     sessionID, authExpiracy, none = \
            base64.b64decode(cookie).split(':')
     self.assertEquals(authExpiracy, '0')
     self.assertEquals(sessionID, self.sessionID)
     for d in reactor.getDelayedCalls():
         d.cancel()
开发者ID:ApsOps,项目名称:flumotion-orig,代码行数:11,代码来源:test_hls_resource.py


示例18: tearDown

    def tearDown(self):
        """Cleanup method after each ``test_*`` method runs; removes timed out
        connections on the reactor and clears the :ivar:`transport`.
        """
        self.transport.clear()  # Clear bytes from the transport.

        for delay in reactor.getDelayedCalls():
            try:
                delay.cancel()
            except (AlreadyCalled, AlreadyCancelled):
                pass
开发者ID:liudonghua123,项目名称:bridgedb,代码行数:11,代码来源:test_email_server.py


示例19: die

 def die(self):        
     # we don't want zombie thread do we ? ;)
     print "Del SocksTools"
     # dirty but yeah
     for i in xrange(0,2):
         for calls in reactor.getDelayedCalls():
             if calls.func == self._twistedLoop and calls.active():
                 print "cancel", calls
                 try: calls.cancel()
                 except Exception as e: print e
         time.sleep(1)
     for port, values in self.proxies.items():
         print "close port ", port
         values[3].reply('Closing proxy on port '+str(port))
         values[5].stopListening()
         values[4].closeConnection()     
     for calls in reactor.getDelayedCalls():
         if calls.func == self._twistedLoop and calls.active():
             print "cancel", calls
             try: calls.cancel()
             except Exception as e: print e
开发者ID:clue-eq-None,项目名称:random_limnoria_plugins,代码行数:21,代码来源:plugin.py


示例20: handle_refuse

    def handle_refuse(self, message):
        """Este método deve ser sobrescrito quando na implementação
            do protocolo, sendo executado sempre que o agente receber
            uma mensagem do tipo FIPA_REFUSE

            :param message: Mensagem FIPA-ACL
        """
        self.received_qtd += 1
        if self.received_qtd == self.cfp_qtd:
            delayed_calls = reactor.getDelayedCalls()
            for call in delayed_calls:
                call.cancel()
开发者ID:ArnoldJunior,项目名称:Pade,代码行数:12,代码来源:protocols.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reactor.getReaders函数代码示例发布时间:2022-05-27
下一篇:
Python reactor.fireSystemEvent函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap