Re: issue with pydo transactions in postgresql

Jacob Smullyan <[email protected]> Mon, 20 Jun 2005 20:08:04 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Mon, Jun 20, 2005 at 07:31:29AM -0400, Jacob Smullyan wrote:
> On Mon, Jun 20, 2005 at 06:27:34PM +1000, Adam Ward wrote:
> > I have also had problems when the underlying connection to the database
> > is lost. However I have been unable to recover from this.
> 
> > Is there a better solution, or do you have any suggestions?
> 
> There isn't a solution per se.  When the underlying connection is
> lost, that is a hard error.  You can try reconnecting, but if the db
> is down how is PyDO supposed to recover?  This class of error can be
> addressed to some degree by the pool mechanism, but to a limited
> extent.  I'm in a rush at the moment, but I'll try to remember to provide details later ....

The details I meant to provide were simply that if you write a
subclass of pydo.dbi.ConnectionPool, you can override the onHandout()
instance method to test a connection before handing it out.  That way,
if a connection went dead -- because the db was restarted, for
instance -- you could replace it with a good one and avoid application
errors.  (This method is actually internal to that class, so, for that
matter, you could write your own connection provider class -- it
really just needs a connect() method, and release(), if you use
pydo.dbi.ConnectionWrapper.)

Tests for the pool mechanism haven't been written yet, so it may be a
bit less solid than the rest; but that will change shortly.

j

-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCt1pkuqamFyFXXLIRAo1/AJ9qrhxrVBhNavXmsSTjj1PoQAHAnACcD1pe
TkTGrkDdm9U7BA0eU891CHw=
=U1nS
-----END PGP SIGNATURE-----