On 05/03/2015 03:03 PM, Arnaud Delobelle wrote:
On 3 May 2015 at 02:22, Greg Ewing<greg.ew...@canterbury.ac.nz>  wrote:
>Guido van Rossum wrote:
>>
>>On Sat, May 2, 2015 at 1:18 PM, Arnaud Delobelle <arno...@gmail.com
>><mailto:arno...@gmail.com>> wrote:
>>
>>     Does this mean that
>>     somehow "await x" guarantees that the coroutine will suspend at least
>>     once?
>
>
>No. First, it's possible for x to finish without yielding.
>But even if x yields, there is no guarantee that the
>scheduler will run something else -- it might just
>resume the same task, even if there is another one that
>could run. It's up to the scheduler whether it
>implements any kind of "fair" scheduling policy.
That's what I understood but the example ('yielding()') provided by
Ron Adam seemed to imply otherwise, so I wanted to clarify.


Guido is correct of course. In examples I've used before with trampolines, a co-routine would be yielded back to the event loop, and if there was any other co-routines in the event loop they would execute first. I'm not sure if async and await can be used with a trampoline type scheduler.

A scheduler might use a timer or priority based system system to schedule events. So yes, it's up to the scheduler and the pep492 is intended to be flexible as to what scheduler is used.

Cheers,
   Ron








_______________________________________________
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