# HG changeset patch # User Alexandre Fayolle # Date 1275127567 0 # Node ID 2604545d7dd9bc4cacdc2b4e086a4e7b7ccc058d # Parent 60a92bf32a18669d5f39f5e0edc5ca75560a9fa5 [win32 SQLServer] connection lost detection The pyodbc driver when connected to SQLServer 2005 reports lost connections in a quite strange way, raising a pyodbc.Error exception with a specific exc.args value. This patch catches these and reconnect properly. diff -r 60a92bf32a18 -r 2604545d7dd9 server/sources/native.py --- a/server/sources/native.py Sat May 29 10:03:50 2010 +0000 +++ b/server/sources/native.py Sat May 29 10:06:07 2010 +0000 @@ -442,6 +442,15 @@ self.warning("trying to reconnect") session.pool.reconnect(self) cursor = self.doexec(session, sql, args) + except (self.DbapiError,), exc: + # We get this one with pyodbc and SQL Server when connection was reset + if exc.args[0] == '08S01': + self.warning("trying to reconnect") + session.pool.reconnect(self) + cursor = self.doexec(session, sql, args) + else: + raise + results = self.process_result(cursor, cbs) assert dbg_results(results) return results diff -r 60a92bf32a18 -r 2604545d7dd9 server/sqlutils.py --- a/server/sqlutils.py Sat May 29 10:03:50 2010 +0000 +++ b/server/sqlutils.py Sat May 29 10:06:07 2010 +0000 @@ -165,6 +165,7 @@ dbapi_module = self.dbhelper.dbapi_module self.OperationalError = dbapi_module.OperationalError self.InterfaceError = dbapi_module.InterfaceError + self.DbapiError = dbapi_module.Error self._binary = dbapi_module.Binary self._process_value = dbapi_module.process_value self._dbencoding = dbencoding