On 1 May 2015 at 20:59, Guido van Rossum <gu...@python.org> wrote:
> On Fri, May 1, 2015 at 12:49 PM, Ron Adam <ron3...@gmail.com> wrote:
>>
>>
>> Another useful async function might be...
>>
>>    async def yielding():
>>        pass
>>
>> In a routine is taking very long time, just inserting "await yielding()"
>> in the long calculation would let other awaitables run.
>>
> That's really up to the scheduler, and a function like this should be
> provided by the event loop or scheduler framework you're using.

Really?  I was under the impression that 'await yielding()' as defined
above would actually not suspend the coroutine at all, therefore not
giving any opportunity for the scheduler to resume another coroutine,
and I thought I understood the PEP well enough.  Does this mean that
somehow "await x" guarantees that the coroutine will suspend at least
once?

To me the async def above was the equivalent of the following in the
'yield from' world:

def yielding():
    return
    yield # Just to make it a generator

Then "yield from yielding()" will not yield at all - which makes its
name rather misleading!

-- 
Arnaud
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to