A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-April/139417.html below:

[Python-Dev] async/await in Python; v2

[Python-Dev] async/await in Python; v2 [Python-Dev] async/await in Python; v2Greg Ewing greg.ewing at canterbury.ac.nz
Thu Apr 23 09:36:23 CEST 2015
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
More information about the Python-Dev mailing list

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