server/sources/native.py
changeset 5982 30985571dbc9
parent 5891 99024ad59223
parent 5975 5120d97e2f7e
child 6019 373a313ee9ec
equal deleted inserted replaced
5981:3472c051da77 5982:30985571dbc9
   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