[Python-ideas] Async API

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Oct 28 01:21:35 CEST 2012


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.

-- 
Greg



More information about the Python-ideas mailing list