[Twisted-Python] OT - adbapi, connection timeouts, mysql - OT

Phil Mayers p.mayers at imperial.ac.uk
Tue Aug 25 11:25:35 EDT 2009

Phil Christensen wrote:
> On Aug 24, 2009, at 9:14 PM, Garret Heaton wrote:
>> On Mon, Aug 24, 2009 at 3:53 PM, Phil Christensen <phil at bubblehouse.org 
>>> wrote:
>>> I feel like I can think of any number of ways running the same  
>>> series of queries twice would be a bad thing. I have some very  
>>> important queries that are run inside a interaction because they do  
>>> a series of operations in sequence. I can't use transactions  
>>> because my tables are MyISAM.
>>> Perhaps I'm jumping at shadows, but automatic re-querying just  
>>> seems dangerous to me. Only the particular application knows when  
>>> it's safe.
>> This is very true, and I should have mentioned it in my reply. Re- 
>> running queries is only possible when you know your application can  
>> do it safely.
>> How would you solve the issue of a lost connection in your case?
> Honestly, I have never actually solved it. I pretty much only write  
> webapps these days, so when a ConnectionLost happens, it just  
> propagates up the stack and displays an error to the user. Not ideal,  
> by any means.

It's hard to apply in the general case, but I like the way Zope handles 
this using the per-request transaction machinery.

Basically, if any processing generates a "retry"able exception, all 
transactions attached to the request are rolled back and the entire 
request re-submitted.

This works really, really well for HTML<->SQL CRUD apps.

I can't see how Twisted could support that currently, given the 
deferToThread == 1 transaction nature of adbapi.

More information about the Twisted-Python mailing list