Re: Re: Reusing connections quixote 2

"Evan Laforge" <[email protected]> Thu, 1 Feb 2007 11:37:34 -0800
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
I do something like this with a SqlRetry class.  It has a SqlRead
method which executes the sql, and if it raises a transient error will
retry n times.  If you pass a function to a Transaction, it wraps it
in 'begin..commit' (and rolls back if an exception escapes) and
retries triansient errors at the transaction level rather than the
statement level.

It's worked well for me.  I don't think I can release it since I wrote
it for work, but it was easy and simple (~300 lines).  The only time
consuming part is gradually finding out what MySQLdb raises for
transient errors and which are permanent (MySQLdb is quite
inconsistent and confusing).