As I said before, this approach will mess transactions badly, as it can change the connection in the middle of a transaction and the caller will be unaware of this as there will be no indication of what happened. The reconnect feature that is implemented by the mysql client library knows if the connection was in the middle of a transaction when it was lost and will indicate this error condition after reconnecting, allowing for a safe recovery from the situation, while the approach outlined below doesn't.
On Tuesday 16 January 2007 17:09, Oleg Broytmann wrote: > On Tue, Jan 16, 2007 at 03:53:39PM +0100, Dr. Markus Gritsch wrote: > > Unfortunately, I had to further modify the previous patch to get > > reconnected in all cases: The __init__ method of the Iteration class > > has also to use the hack. Further, due to my missing insight into > > the inner workings of SQLObject, I totally neglect the self._pool > > stuff of DBAPI, which (I have the feeling) is not perfect -- > > therefore I labeled the patch to be a hack. > > May be instead of going all the way down the hackish path we could > think of a more generic approach. Let's add an empty (no-op) abstract > method to the DBAPI class > > def wakeup(self, raw_connection): > return raw_connection > > that will be called from getConnection and Iteration. Than > MySQLConnection could overide the method. Something like this: > > def wakeup(self, raw_connection): > try: > raw_connection.ping() > return raw_connection > except MySQLdb.OperationalError, e: > if e.args[0] in ( 2006, 2013 ): # SERVER_GONE or > SERVER_LOST error print 'reconnecting because of', e > conn = self.makeConnection() > return conn > else: > raise > > Oleg. -- Dan ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss