466 args = self.merge_args(args, qargs) |
466 args = self.merge_args(args, qargs) |
467 assert isinstance(sql, basestring), repr(sql) |
467 assert isinstance(sql, basestring), repr(sql) |
468 try: |
468 try: |
469 cursor = self.doexec(session, sql, args) |
469 cursor = self.doexec(session, sql, args) |
470 except (self.OperationalError, self.InterfaceError): |
470 except (self.OperationalError, self.InterfaceError): |
|
471 if session.mode == 'write': |
|
472 # do not attempt to reconnect if there has been some write |
|
473 # during the transaction |
|
474 raise |
471 # FIXME: better detection of deconnection pb |
475 # FIXME: better detection of deconnection pb |
472 self.warning("trying to reconnect") |
476 self.warning("trying to reconnect") |
473 session.pool.reconnect(self) |
477 session.pool.reconnect(self) |
474 cursor = self.doexec(session, sql, args) |
478 cursor = self.doexec(session, sql, args) |
475 except (self.DbapiError,), exc: |
479 except (self.DbapiError,), exc: |
476 # We get this one with pyodbc and SQL Server when connection was reset |
480 # We get this one with pyodbc and SQL Server when connection was reset |
477 if exc.args[0] == '08S01': |
481 if exc.args[0] == '08S01' and session.mode != 'write': |
478 self.warning("trying to reconnect") |
482 self.warning("trying to reconnect") |
479 session.pool.reconnect(self) |
483 session.pool.reconnect(self) |
480 cursor = self.doexec(session, sql, args) |
484 cursor = self.doexec(session, sql, args) |
481 else: |
485 else: |
482 raise |
486 raise |