[Python-ideas] Async API

Yury Selivanov yselivanov.ml at gmail.com
Sun Oct 28 01:45:13 CEST 2012


On 2012-10-27, at 7:21 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> Guido van Rossum wrote:
> 
>> The example would have to set some flag indicating it has a result
>> after the first yield (i.e. before entering the finally, or at least
>> before yielding in the finally clause). And the timeout callback would
>> have to check this flag. This makes it slightly awkward to design a
>> general-purpose timeout mechanism for tasks written in this style --
>> if you expect a timeout or cancellation you must protect your cleanup
>> code from it by using some API.
> 
> This is where having a way to find out whether a generator
> is in a finally clause would help. It would allow the scheduler
> to take care of this transparently.

Right.  But now I'm not sure this approach will work with yield-froms.
As when you yield-fromming scheduler knows nothing about the chain of 
generators, as it's all hidden in the yield-from implementation.

-
Yury



More information about the Python-ideas mailing list