MCPcopy Create free account
hub / github.com/EasyIME/PIME / convert_yielded

Function convert_yielded

python/python3/tornado/gen.py:848–876  ·  view source on GitHub ↗

Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. This has the side effect of starting any coroutines that did not start themselves, similar to `asyncio.ensure_future`. If the `~functools.singledispatch` library is avail

(yielded: _Yieldable)

Source from the content-addressed store, hash-verified

846
847
848def convert_yielded(yielded: _Yieldable) -> Future:
849 """Convert a yielded object into a `.Future`.
850
851 The default implementation accepts lists, dictionaries, and
852 Futures. This has the side effect of starting any coroutines that
853 did not start themselves, similar to `asyncio.ensure_future`.
854
855 If the `~functools.singledispatch` library is available, this function
856 may be extended to support additional types. For example::
857
858 @convert_yielded.register(asyncio.Future)
859 def _(asyncio_future):
860 return tornado.platform.asyncio.to_tornado_future(asyncio_future)
861
862 .. versionadded:: 4.1
863
864 """
865 if yielded is None or yielded is moment:
866 return moment
867 elif yielded is _null_future:
868 return _null_future
869 elif isinstance(yielded, (list, dict)):
870 return multi(yielded) # type: ignore
871 elif is_future(yielded):
872 return typing.cast(Future, yielded)
873 elif isawaitable(yielded):
874 return _wrap_awaitable(yielded) # type: ignore
875 else:
876 raise BadYieldError("yielded unknown object %r" % (yielded,))
877
878
879convert_yielded = singledispatch(convert_yielded)

Callers 4

runMethod · 0.90
to_asyncio_futureFunction · 0.90
with_timeoutFunction · 0.85
handle_yieldMethod · 0.85

Calls 3

is_futureFunction · 0.90
multiFunction · 0.85
BadYieldErrorClass · 0.85

Tested by

no test coverage detected