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


Python ioloop.TimeoutError方法代码示例

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


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

示例1: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        # Set a short timeout and exceed it.
        @gen_test(timeout=0.1)
        def test(self):
            yield gen.Task(self.io_loop.add_timeout, self.io_loop.time() + 1)

        # This can't use assertRaises because we need to inspect the
        # exc_info triple (and not just the exception object)
        try:
            test(self)
            self.fail("did not get expected exception")
        except ioloop.TimeoutError:
            # The stack trace should blame the add_timeout line, not just
            # unrelated IOLoop/testing internals.
            self.assertIn(
                "gen.Task(self.io_loop.add_timeout, self.io_loop.time() + 1)",
                traceback.format_exc())

        self.finished = True 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:21,代码来源:testing_test.py

示例2: open

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def open(self, timeout=None):
        logger.debug('socket connecting')
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
        self.stream = iostream.IOStream(sock)

        try:
            connect = self.stream.connect((self.host, self.port))
            if timeout is not None:
                yield self.with_timeout(timeout, connect)
            else:
                yield connect
        except (socket.error, IOError, ioloop.TimeoutError) as e:
            message = 'could not connect to {}:{} ({})'.format(self.host, self.port, e)
            raise TTransportException(
                type=TTransportException.NOT_OPEN,
                message=message)

        raise gen.Return(self) 
开发者ID:XiaoMi,项目名称:galaxy-sdk-python,代码行数:20,代码来源:TTornado.py

示例3: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        # Set a short timeout and exceed it.
        @gen_test(timeout=0.1)
        def test(self):
            yield gen.sleep(1)

        # This can't use assertRaises because we need to inspect the
        # exc_info triple (and not just the exception object)
        try:
            test(self)
            self.fail("did not get expected exception")
        except ioloop.TimeoutError:
            # The stack trace should blame the add_timeout line, not just
            # unrelated IOLoop/testing internals.
            self.assertIn("gen.sleep(1)", traceback.format_exc())

        self.finished = True 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:19,代码来源:testing_test.py

示例4: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        # Set a short timeout and exceed it.
        @gen_test(timeout=0.1)
        def test(self):
            yield gen.sleep(1)

        # This can't use assertRaises because we need to inspect the
        # exc_info triple (and not just the exception object)
        try:
            test(self)
            self.fail("did not get expected exception")
        except ioloop.TimeoutError:
            # The stack trace should blame the add_timeout line, not just
            # unrelated IOLoop/testing internals.
            self.assertIn(
                "gen.sleep(1)",
                traceback.format_exc())

        self.finished = True 
开发者ID:tp4a,项目名称:teleport,代码行数:21,代码来源:testing_test.py

示例5: open

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def open(self, timeout=None):
        logger.debug('koneksi ke server')
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
        self.stream = iostream.IOStream(sock)
        try:
            connect = self.stream.connect((self.host, self.port))
            if timeout is not None:
                yield self.with_timeout(timeout, connect)
            else:
                yield connect
        except (socket.error, IOError, ioloop.TimeoutError) as e:
            message = 'could not connect to {}:{} ({})'.format(self.host, self.port, e)
            raise TTransportException(
                type=TTransportException.NOT_OPEN,
                message=message)
        raise gen.Return(self) 
开发者ID:stya535,项目名称:SOLO,代码行数:18,代码来源:TTornado.py

示例6: test_no_timeout_environment_variable

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_no_timeout_environment_variable(self):
        @gen_test(timeout=0.01)
        def test_short_timeout(self):
            time = self.io_loop.time
            yield gen.Task(self.io_loop.add_timeout, time() + 1)

        # Uses environment-variable timeout of 0.1, times out.
        with set_environ('ASYNC_TEST_TIMEOUT', '0.1'):
            with self.assertRaises(ioloop.TimeoutError):
                test_short_timeout(self)

        self.finished = True 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:14,代码来源:testing_test.py

示例7: test_native_coroutine_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_native_coroutine_timeout(self):
        # Set a short timeout and exceed it.
        namespace = exec_test(globals(), locals(), """
        @gen_test(timeout=0.1)
        async def test(self):
            await gen.sleep(1)
        """)

        try:
            namespace['test'](self)
            self.fail("did not get expected exception")
        except ioloop.TimeoutError:
            self.finished = True 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:15,代码来源:testing_test.py

示例8: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        @gen.coroutine
        def f():
            yield gen.Task(self.io_loop.add_timeout, self.io_loop.time() + 1)
        self.assertRaises(TimeoutError, self.io_loop.run_sync, f, timeout=0.01) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:ioloop_test.py

示例9: test_no_timeout_environment_variable

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_no_timeout_environment_variable(self):
        @gen_test(timeout=0.01)
        def test_short_timeout(self):
            yield gen.sleep(1)

        # Uses environment-variable timeout of 0.1, times out.
        with set_environ("ASYNC_TEST_TIMEOUT", "0.1"):
            with self.assertRaises(ioloop.TimeoutError):
                test_short_timeout(self)

        self.finished = True 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:13,代码来源:testing_test.py

示例10: test_native_coroutine_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_native_coroutine_timeout(self):
        # Set a short timeout and exceed it.
        @gen_test(timeout=0.1)
        async def test(self):
            await gen.sleep(1)

        try:
            test(self)
            self.fail("did not get expected exception")
        except ioloop.TimeoutError:
            self.finished = True 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:13,代码来源:testing_test.py

示例11: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        @gen.coroutine
        def f():
            yield gen.sleep(1)

        self.assertRaises(TimeoutError, self.io_loop.run_sync, f, timeout=0.01) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:8,代码来源:ioloop_test.py

示例12: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        # Set a short timeout and exceed it.
        @gen_test(timeout=0.1)
        def test(self):
            yield gen.Task(self.io_loop.add_timeout, self.io_loop.time() + 1)

        with self.assertRaises(ioloop.TimeoutError):
            test(self)

        self.finished = True 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:12,代码来源:testing_test.py

示例13: test_no_timeout_environment_variable

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_no_timeout_environment_variable(self):
        @gen_test(timeout=0.01)
        def test_short_timeout(self):
            yield gen.sleep(1)

        # Uses environment-variable timeout of 0.1, times out.
        with set_environ('ASYNC_TEST_TIMEOUT', '0.1'):
            with self.assertRaises(ioloop.TimeoutError):
                test_short_timeout(self)

        self.finished = True 
开发者ID:tp4a,项目名称:teleport,代码行数:13,代码来源:testing_test.py

示例14: test_timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import TimeoutError [as 别名]
def test_timeout(self):
        @gen.coroutine
        def f():
            yield gen.sleep(1)
        self.assertRaises(TimeoutError, self.io_loop.run_sync, f, timeout=0.01) 
开发者ID:tp4a,项目名称:teleport,代码行数:7,代码来源:ioloop_test.py


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