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


Python gen.is_coroutine_function方法代码示例

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


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

示例1: post

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def post(self, path):
        assert self.get_body_arguments("appmode_action")[0] == "delete"
        path = path.strip('/')
        self.log.info('Appmode deleting: %s', path)

        # delete session, including the kernel
        sm = self.session_manager
        if gen.is_coroutine_function(sm.get_session):
            s = yield sm.get_session(path=path)
        else:
            s = sm.get_session(path=path)
        if gen.is_coroutine_function(sm.delete_session):
            yield sm.delete_session(session_id=s['id'])
        else:
            sm.delete_session(session_id=s['id'])

        # delete tmp copy
        cm = self.contents_manager
        cm.delete(path)
        self.finish()

    #=========================================================================== 
开发者ID:oschuett,项目名称:appmode,代码行数:24,代码来源:server_extension.py

示例2: is_tornado_coroutine

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def is_tornado_coroutine(func):
    """
    Return whether *func* is a Tornado coroutine function.
    Running coroutines are not supported.
    """
    if 'tornado.gen' not in sys.modules:
        return False
    gen = sys.modules['tornado.gen']
    if not hasattr(gen, "is_coroutine_function"):
        # Tornado version is too old
        return False
    return gen.is_coroutine_function(func) 
开发者ID:pywren,项目名称:pywren-ibm-cloud,代码行数:14,代码来源:cloudpickle.py

示例3: test_is_coroutine_function

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def test_is_coroutine_function(self):
        self.finished = True

        def f():
            yield gen.moment

        coro = gen.coroutine(f)
        self.assertFalse(gen.is_coroutine_function(f))
        self.assertTrue(gen.is_coroutine_function(coro))
        self.assertFalse(gen.is_coroutine_function(coro())) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:12,代码来源:gen_test.py

示例4: test_retry

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def test_retry(self):
        assert gen.is_coroutine_function(_retryable_coroutine)
        thing = NoIOErrorAfterCount(5)
        yield _retryable_coroutine(thing)
        assert thing.counter == thing.count 
开发者ID:jd,项目名称:tenacity,代码行数:7,代码来源:test_tornado.py

示例5: test_stop_after_attempt

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def test_stop_after_attempt(self):
        assert gen.is_coroutine_function(_retryable_coroutine)
        thing = NoIOErrorAfterCount(2)
        try:
            yield _retryable_coroutine_with_2_attempts(thing)
        except RetryError:
            assert thing.counter == 2 
开发者ID:jd,项目名称:tenacity,代码行数:9,代码来源:test_tornado.py

示例6: test_old_tornado

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def test_old_tornado(self):
        old_attr = gen.is_coroutine_function
        try:
            del gen.is_coroutine_function

            # is_coroutine_function was introduced in tornado 4.5;
            # verify that we don't *completely* fall over on old versions
            @retry
            def retryable(thing):
                pass
        finally:
            gen.is_coroutine_function = old_attr 
开发者ID:jd,项目名称:tenacity,代码行数:14,代码来源:test_tornado.py

示例7: is_tornado_coroutine

# 需要导入模块: from tornado import gen [as 别名]
# 或者: from tornado.gen import is_coroutine_function [as 别名]
def is_tornado_coroutine(func):
  """
  Return whether *func* is a Tornado coroutine function.
  Running coroutines are not supported.
  """
  if 'tornado.gen' not in sys.modules:
    return False
  gen = sys.modules['tornado.gen']
  if not hasattr(gen, "is_coroutine_function"):
    # Tornado version is too old
    return False
  return gen.is_coroutine_function(func) 
开发者ID:WeBankFinTech,项目名称:eggroll,代码行数:14,代码来源:cloudpickle.py


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