[Python-Dev] PEP 492: What is the real goal?

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Apr 30 14:08:36 CEST 2015


Paul Moore wrote:
> Also, can I run
> the produce/consume just by calling produce()? My impression is that
> with asyncio I need an event loop - which "traditional" coroutines
> don't need.

The Pythonic way to do things like that is to write
the producer as a generator, and the consumer as a
loop that iterates over it. Or the consumer as a
generator, and the producer as a loop that send()s
things into it.

To do it symmetrically, you would need to write them
both as generators (or async def functions or whatever)
plus a mini event loop to tie the two together.

-- 
Greg


More information about the Python-Dev mailing list