[PyGreSQL] Re: [Zope] PyGres DB Connection in Zope dropswhen many Usersare added(UserDB)

Hannu Krosing hannu at tm.ee
Wed Apr 26 11:52:42 EDT 2000


Stephan Richter wrote:
> 
> >try:
> >     try:
> >         ob=self.sqlUserQuery(username=name)
> >     except:
> >         # first get the PyGreSQL connection object
> >         conn = getattr(self,self.conn_id)
> >         # then "reset" it
> >         conn.connect(conn.connection_string)
> >         # and retry the query
> >         ob=self.sqlUserQuery(username=name)
> >except:
> >     # failing after reset means a more serius problem (like bad query)
> >     return None
> 
> I put the extra reconnect code in every method that used the DB connection,
> since you do not know, whether the getUser is accessed first after loosing
> the connection.

Possible. For me it was enough to put it in getUser. 

I tested it by doing

/etc/rc.d/init.d/postgresql restart

do drop the connection while zope was running and it continued without a hitch
.

-------------
Hannu




More information about the PyGreSQL mailing list