[Python-ideas] Async API

Yury Selivanov yselivanov.ml at gmail.com
Thu Oct 25 03:07:45 CEST 2012

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

> On 25/10/12 11:47, Yury Selivanov wrote:
>> Cleanup code for a DB connection
>> *will* need to run queries to the database (at least in some circumstances).
> That smells like a design problem to me. If something goes wrong,
> the most you should have to do is roll back any transactions
> you were in the middle of. Trying to perform further queries
> is just inviting more trouble.

Right.  And that rolling back - a tiny db query "rollback" - is an
async code, and where there is an async code, no matter how tiny and fast, - 
scheduler has an opportunity to screw it up.

Guido's 'with protected_finally' should work, although it probably
will look weird for for people unfamiliar with coroutines and this
particular problem.


More information about the Python-ideas mailing list