[Python-Dev] PEP 492: async/await in Python; version 5
yselivanov.ml at gmail.com
Thu May 7 20:01:48 CEST 2015
On 2015-05-07 1:42 PM, Guido van Rossum wrote:
> On Tue, May 5, 2015 at 3:36 PM, Rajiv Kumar <rajiv.kumar at gmail.com> wrote:
>> I wrote a little example that has a bare-bones implementation of Go
>> style channels via a custom event loop. I used it to translate the prime
>> sieve example from Go almost directly to Python. The code uses "message
>> = await channel.receive()" to mimic Go's "message <- channel". Instead of
>> using "go func()" to fire off a goroutine, I add the PEP492 coroutine to my
>> simple event loop.
> Cool example!
> It's not an efficient implementation - really just a proof of concept that
>> you can use async/await in your own code without any reference to asyncio.
>> I ended up writing it as I was thinking about how PEP 342 style coroutines
>> might look like in an async/await world.
>> In the course of writing this, I did find that it would be useful to have
>> the PEP document how event loops should advance the coroutines (via
>> .send(None) for example). It would also be helpful to have the semantics of
>> how await interacts with different kinds of awaitables documented. I had to
>> play with Yury's implementation to see what it does if the __await__ just
>> returns iter([1,2,3]) for example.
> I've found this too. :-) Yury, perhaps you could show a brief example in
> the PEP of how to "drive" a coroutine from e.g. main()?
OK, will do!
More information about the Python-Dev