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


Python ioloop.PollIOLoop方法代码示例

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


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

示例1: test_remove_timeout_cleanup

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import PollIOLoop [as 别名]
def test_remove_timeout_cleanup(self):
        # Add and remove enough callbacks to trigger cleanup.
        # Not a very thorough test, but it ensures that the cleanup code
        # gets executed and doesn't blow up.  This test is only really useful
        # on PollIOLoop subclasses, but it should run silently on any
        # implementation.
        for i in range(2000):
            timeout = self.io_loop.add_timeout(self.io_loop.time() + 3600,
                                               lambda: None)
            self.io_loop.remove_timeout(timeout)
        # HACK: wait two IOLoop iterations for the GC to happen.
        self.io_loop.add_callback(lambda: self.io_loop.add_callback(self.stop))
        self.wait() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:15,代码来源:ioloop_test.py

示例2: test_timeout_with_arguments

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import PollIOLoop [as 别名]
def test_timeout_with_arguments(self):
        # This tests that all the timeout methods pass through *args correctly.
        results = []
        self.io_loop.add_timeout(self.io_loop.time(), results.append, 1)
        self.io_loop.add_timeout(datetime.timedelta(seconds=0),
                                 results.append, 2)
        self.io_loop.call_at(self.io_loop.time(), results.append, 3)
        self.io_loop.call_later(0, results.append, 4)
        self.io_loop.call_later(0, self.stop)
        self.wait()
        # The asyncio event loop does not guarantee the order of these
        # callbacks, but PollIOLoop does.
        self.assertEqual(sorted(results), [1, 2, 3, 4]) 
开发者ID:tp4a,项目名称:teleport,代码行数:15,代码来源:ioloop_test.py

示例3: run_python

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import PollIOLoop [as 别名]
def run_python(self, *statements):
        statements = [
            'from tornado.ioloop import IOLoop, PollIOLoop',
            'classname = lambda x: x.__class__.__name__',
        ] + list(statements)
        args = [sys.executable, '-c', '; '.join(statements)]
        return native_str(subprocess.check_output(args)).strip() 
开发者ID:tp4a,项目名称:teleport,代码行数:9,代码来源:ioloop_test.py

示例4: test_default

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import PollIOLoop [as 别名]
def test_default(self):
        if asyncio is not None:
            # When asyncio is available, it is used by default.
            cls = self.run_python('print(classname(IOLoop.current()))')
            self.assertEqual(cls, 'AsyncIOMainLoop')
            cls = self.run_python('print(classname(IOLoop()))')
            self.assertEqual(cls, 'AsyncIOLoop')
        else:
            # Otherwise, the default is a subclass of PollIOLoop
            is_poll = self.run_python(
                'print(isinstance(IOLoop.current(), PollIOLoop))')
            self.assertEqual(is_poll, 'True') 
开发者ID:tp4a,项目名称:teleport,代码行数:14,代码来源:ioloop_test.py

示例5: initialize

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import PollIOLoop [as 别名]
def initialize(self, **kwargs):
            self.real_io_loop = PollIOLoop(make_current=False)  # type: ignore
            reactor = self.real_io_loop.run_sync(gen.coroutine(TornadoReactor))
            super(LayeredTwistedIOLoop, self).initialize(reactor=reactor, **kwargs)
            self.add_callback(self.make_current) 
开发者ID:tp4a,项目名称:teleport,代码行数:7,代码来源:twisted_test.py


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