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. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- 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