[Zope] Automatically restarting ZPyGreSQLDA connection

Jim Fulton jim@digicool.com
Tue, 01 Jun 1999 09:58:29 -0400


Hannu Krosing wrote:
> 
> Hi,
> 
> Is there any way to catch the error from a Zope Database
> Adapter and restart it ?
> 
> I'm experiencing what I suspect are timeout problems (sometimes
> a bunch of imapd's drive the load to >10 and make the computer
> really slow).
> 
> The symptom is that at some point I get a traceback from
> _pgmodule instead of nice page.
> 
> The only way to fix it after that is going to manage screens and
> shutdown/startup the connection
> 
> I would like to catch this exception and do the
> shutdown/startup automatically (and perhaps log that it happened)
> 
> Or would the only reasonable place to do such things be inside
> the DA ?

You should try to catch the exception in the DA.

> The latter should not be too hard, just try: to send an empty query
> before the real one (con.query("")) and in except: open a new one
> (and log the error if desired)

Why not just catch the exception on the real query.
 
> The overhead should be almost nothing, at least when using domain
> sockets.

I had a similar problem with the Solid DA, although, rather than
getting exceptions, I just got strange results. :/.
I ended up modifying the DA to reconnect if more than one hour had elepsed
since the previous query.  This seemed to have take care of the problem.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.