On Tue, Jul 28, 2015 at 2:41 PM, Javier <jcarm...@gmail.com> wrote: > I think that force the developer to 'yield from' all function calls to keep > async capabilities is a big mistake, it should be more flexible, like this: > > import asyncio > > @asyncio.coroutine > fun non_blocking_io(): > """ Everybody knows I'm doing non blocking IO """ > ... > > fun foo(): > """ I invoke functions that do IO stuff """ > data = yield from non_blocking_io() > yield from store_data_db(data) > ... > > fun bar(): > """ I don't know what foo implementation does """ > foo() > > asyncio.async(bar())
Do you have a proposal for implementing this? What does "yield from" actually do here? How does the event loop know that foo is waiting for something and what it is waiting for? > Does python 3.5 await/async solve this? Yes and no. await is basically equivalent to yield from with extra validation, so you still can't use them like what you have above. But native coroutines are also clearly not generators as they lack __next__ and __iter__ methods, so maybe there will be less temptation to try to use them without using await / yield from. -- https://mail.python.org/mailman/listinfo/python-list