<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, May 2, 2015 at 1:18 PM, Arnaud Delobelle <span dir="ltr"><<a href="mailto:arnodel@gmail.com" target="_blank">arnodel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 1 May 2015 at 20:59, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
> On Fri, May 1, 2015 at 12:49 PM, Ron Adam <<a href="mailto:ron3200@gmail.com">ron3200@gmail.com</a>> wrote:<br>
>><br>
>><br>
>> Another useful async function might be...<br>
>><br>
>> async def yielding():<br>
>> pass<br>
>><br>
>> In a routine is taking very long time, just inserting "await yielding()"<br>
>> in the long calculation would let other awaitables run.<br>
>><br>
> That's really up to the scheduler, and a function like this should be<br>
> provided by the event loop or scheduler framework you're using.<br>
<br>
</span>Really? I was under the impression that 'await yielding()' as defined<br>
above would actually not suspend the coroutine at all, therefore not<br>
giving any opportunity for the scheduler to resume another coroutine,<br>
and I thought I understood the PEP well enough. Does this mean that<br>
somehow "await x" guarantees that the coroutine will suspend at least<br>
once?<br></blockquote><div><br></div><div>You're correct. That's why I said it should be left up to the framework -- ultimately what you *do* have to put in such a function has to be understood by the framenwork. And that's why in other messages I've used await asyncio.sleep(0) as an example. Look up its definition.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
To me the async def above was the equivalent of the following in the<br>
'yield from' world:<br>
<br>
def yielding():<br>
return<br>
yield # Just to make it a generator<br>
<br>
Then "yield from yielding()" will not yield at all - which makes its<br>
name rather misleading!<span class="HOEnZb"></span><br></blockquote></div><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>