[Python-ideas] Async API
Guido van Rossum
guido at python.org
Thu Oct 25 04:51:04 CEST 2012
On Wed, Oct 24, 2012 at 7:28 PM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> On 2012-10-24, at 9:34 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> [...]
>> (Note that in the face of preemption, I don't think it's possible
>> to solve this problem completely without language support, because
>> there will always be a small window of opportunity between
>> entering the finally clause and getting into the with-statement
>> or whatever that you're using to block asynchronous signals.)
>
> Agree.
>
> In my experience, though, broken finally blocks due to interruption
> by a signal is a very rare thing (again, that maybe different for
> someone else.)
We're far from our starting point: in a the yield-from (or yield)
world, there are no truly async interrupts, but anything that yields
may be interrupted, if we decide to implement timeouts by throwing an
exception into the generator (which seems the logical thing to do).
The with-statement can deal with this fine (there's no yield between
entering the finally and entering the with-block) but making the
cleanup into its own task (like Steve proposed) sounds fine too.
In any case this sounds like something that each framework should
decide for itself.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list