Victor Stinner wrote: > A huge part of the asyncio module is based on "yield from fut" where fut is > a Future object. > > How do you write this using the PEP 3152? Do you need to call an artifical > method like "cocall fut.return_self()" where the return_self() method simply > returns fut? In a PEP 3152 world, Future objects and the like would be expected to implement __cocall__, just as in a PEP 492 world they would be expected to implement __await__. > @asyncio.coroutine currently calls a function and *then* check if it should > yields from it or not: > > res = func(*args, **kw) > if isinstance(res, futures.Future) or inspect.isgenerator(res): > res = yield from res To accommodate the possibility of func being a cofunction, you would need to add something like if is_cofunction(func): res = yield from costart(func, *args, **kw) else: # as above -- Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4