[Python-ideas] Async API

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 24 23:30:04 CEST 2012


Yury Selivanov wrote:

> It's not about try..finally nesting, it's about Scheduler being aware
> that a coroutine is in its 'finally' block and thus shouldn't be interrupted
> at the moment

It would be a bad idea to make a close() method, or anything else
that might be needed for cleanup purposes, be a 'yield from' call.
If it's an ordinary function, it can't be interrupted in the world
we're talking about, so the PEP 419 problem doesn't apply.

If I were feeling in a radical mood, I might go as far as suggesting
that 'yield' and 'yield from' be syntactically forbidden inside
a finally clause. That would force you to design your cleanup
code to be safe from interruptions.

-- 
Greg



More information about the Python-ideas mailing list