当前位置: 首页>>代码示例>>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;未经允许,请勿转载。