[Python-ideas] Async API

Yury Selivanov yselivanov.ml at gmail.com
Thu Oct 25 00:47:02 CEST 2012


Greg,

On 2012-10-24, at 5:30 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> 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.

I'm not sure it would be a good idea... Cleanup code for a DB connection
*will* need to run queries to the database (at least in some circumstances).  
And we can't make them blocking.

-
Yury


More information about the Python-ideas mailing list