當前位置: 首頁>>代碼示例>>Python>>正文


Python BaseChannel.start方法代碼示例

本文整理匯總了Python中pypeman.channels.BaseChannel.start方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseChannel.start方法的具體用法?Python BaseChannel.start怎麽用?Python BaseChannel.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pypeman.channels.BaseChannel的用法示例。


在下文中一共展示了BaseChannel.start方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_loop_slow2

# 需要導入模塊: from pypeman.channels import BaseChannel [as 別名]
# 或者: from pypeman.channels.BaseChannel import start [as 別名]
    def test_loop_slow2(self):
        """ slow tasks delay can be configured """
        import pypeman.debug
        pypeman.debug.enable_slow_log_stats()
        self.setup_evt_loop(slow_cb_duration=0.05)
        stats = pypeman.debug.stats

        # logger = self.logger # get default test logger
        # handler = self.loghandler # get test log handler

        tst_logger = logging.getLogger('tests.debug.main_loop.slow')
        print(tst_logger.handlers)

        loop = self.loop
        chan = BaseChannel(name="test_loop_slow2", loop=loop)
        n1 = SimpleTestNode(delay=0.03, async_delay=0, logger=tst_logger, loop=loop)
        n2 = SimpleTestNode(delay=0.06, logger=tst_logger, loop=loop)
        chan.add(n1)
        chan.add(n2)

        msg = generate_msg()
        # Launch channel processing
        self.loop.run_until_complete(chan.start())
        self.loop.run_until_complete(chan.handle(msg))
        # handler.show_entries()
        self.assertEqual(len(stats), 1, "should have 1 slow tasks, not %d" % len(stats))
        pypeman.debug.show_slow_log_stats()
        self.loop.close()
開發者ID:Zluurk,項目名稱:pypeman,代碼行數:30,代碼來源:test_debug.py

示例2: test_loop_slow

# 需要導入模塊: from pypeman.channels import BaseChannel [as 別名]
# 或者: from pypeman.channels.BaseChannel import start [as 別名]
    def test_loop_slow(self):
        """ main loop logs slow tasks """
        import pypeman.debug
        pypeman.debug.enable_slow_log_stats()
        stats = pypeman.debug.stats
        self.setup_evt_loop()

        # logger = self.logger # get default test logger
        # handler = self.loghandler # get test log handler

        tst_logger = logging.getLogger('tests.debug.main_loop.slow')
        print("HANDLERS", tst_logger.handlers)

        loop = self.loop
        chan = BaseChannel(name="test_loop_slow", loop=loop)
        n1 = SimpleTestNode(delay=0.01, async_delay=0, logger=tst_logger, loop=loop)
        n2 = SimpleTestNode(delay=0.12, async_delay=0, logger=tst_logger, loop=loop)
        n3 = SimpleTestNode(delay=0.11, async_delay=0, logger=tst_logger, loop=loop)
        chan.add(n1)
        chan.add(n2)
        chan.add(n3)

        msg = generate_msg()
        # Launch channel processing
        t0 = time.time()
        print("start channel %.4f" % (time.time() - t0))

        self.loop.run_until_complete(chan.start())
        print("channel started %.4f" % (time.time() - t0))

        self.loop.run_until_complete(chan.handle(msg))
        print("msg handled %.4f" % (time.time() - t0))
        # handler.show_entries()

        self.assertEqual(len(stats), 2, "should have 2 slow tasks, not %d" % len(stats))
        self.loop.close()
開發者ID:Zluurk,項目名稱:pypeman,代碼行數:38,代碼來源:test_debug.py


注:本文中的pypeman.channels.BaseChannel.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。