本文整理匯總了Python中backports_abc.isawaitable方法的典型用法代碼示例。如果您正苦於以下問題:Python backports_abc.isawaitable方法的具體用法?Python backports_abc.isawaitable怎麽用?Python backports_abc.isawaitable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類backports_abc
的用法示例。
在下文中一共展示了backports_abc.isawaitable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: convert_yielded
# 需要導入模塊: import backports_abc [as 別名]
# 或者: from backports_abc import isawaitable [as 別名]
def convert_yielded(yielded):
"""Convert a yielded object into a `.Future`.
The default implementation accepts lists, dictionaries, and Futures.
If the `~functools.singledispatch` library is available, this function
may be extended to support additional types. For example::
@convert_yielded.register(asyncio.Future)
def _(asyncio_future):
return tornado.platform.asyncio.to_tornado_future(asyncio_future)
.. versionadded:: 4.1
"""
# Lists and dicts containing YieldPoints were handled earlier.
if isinstance(yielded, (list, dict)):
return multi(yielded)
elif is_future(yielded):
return yielded
elif isawaitable(yielded):
return _wrap_awaitable(yielded)
else:
raise BadYieldError("yielded unknown object %r" % (yielded,))
示例2: isawaitable
# 需要導入模塊: import backports_abc [as 別名]
# 或者: from backports_abc import isawaitable [as 別名]
def isawaitable(x):
return False
示例3: isawaitable
# 需要導入模塊: import backports_abc [as 別名]
# 或者: from backports_abc import isawaitable [as 別名]
def isawaitable(x): # type: ignore
return False