本文整理汇总了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()
#===========================================================================
示例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)
示例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()))
示例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
示例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
示例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
示例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)