[Python-Dev] async/await in Python; v2 (original) (raw)

Andrew Svetlov andrew.svetlov at gmail.com
Thu Apr 23 11:39:48 CEST 2015


Greg, how waiting for multiple cocalls should look and work?

In asyncio when I need to wait for two and more coroutines/futures I use asyncio.gather():

yield from gather(coro1(a1, a2), coro2(), fut3)

From my understanding to use cofunctions I must wrap it with costart call:

yield from gather(costart(coro1, a1, a2), costart(coro2), fut3)

That looks weird.

There are other places in asyncio API those accept coroutines or futures as parameters, not only Task() and async().

On Thu, Apr 23, 2015 at 12:25 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Yury Selivanov wrote:

I think that the problem of forgetting 'yield from' is a bit exaggerated. Yes, I myself forgot 'yield from' once or twice. But that's it, it has never happened since. I think it's more likely to happen when you start with an ordinary function, then discover that it needs to be suspendable, so you need to track down all the places that call it, and all the places that call those, etc. PEP 3152 ensures that you get clear diagnostics if you miss any. -- Greg


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com

-- Thanks, Andrew Svetlov



More information about the Python-Dev mailing list