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-December/142445.html below:

[Python-Dev] async/await behavior on multiple calls

[Python-Dev] async/await behavior on multiple callsYury Selivanov yselivanov.ml at gmail.com
Tue Dec 15 15:24:52 EST 2015
Hi Roy and Guido,

On 2015-12-15 3:08 PM, Guido van Rossum wrote:
[..]
>
> I don't know how long you have been using async/await, but I wonder if 
> it's possible that you just haven't gotten used to the typical usage 
> patterns? In particular, your claim "anything that takes an 
> `awaitable` has to know that it wasn't already awaited" makes me sound 
> that you're just using it in an atypical way (perhaps because your 
> model is based on other languages). In typical asyncio code, one does 
> not usually take an awaitable, wait for it, and then return it -- one 
> either awaits it and then extracts the result, or one returns it 
> without awaiting it.

I agree.  Holding a return value just so that coroutine can return it 
again seems wrong to me.

However, since coroutines are now a separate type (although they share a 
lot of code with generators internally), maybe we can change them to 
throw an error when they are awaited on more than one time?

That should be better than letting them return `None`:

     coro = coroutine()
     await coro
     await coro  # <- will raise RuntimeError


I'd also add a check that the coroutine isn't being awaited by more than 
one coroutine simultaneously (another, completely different issue, more 
on which here: https://github.com/python/asyncio/issues/288).  This was 
fixed in asyncio in debug mode, but ideally, we should fix this in the 
interpreter core.

Yury
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