482 # do not attempt to reconnect if there has been some write |
482 # do not attempt to reconnect if there has been some write |
483 # during the transaction |
483 # during the transaction |
484 raise |
484 raise |
485 # FIXME: better detection of deconnection pb |
485 # FIXME: better detection of deconnection pb |
486 self.warning("trying to reconnect") |
486 self.warning("trying to reconnect") |
487 session.cnxset.reconnect(self) |
487 session.cnxset.reconnect() |
488 cursor = self.doexec(session, sql, args) |
488 cursor = self.doexec(session, sql, args) |
489 except self.DbapiError as exc: |
489 except self.DbapiError as exc: |
490 # We get this one with pyodbc and SQL Server when connection was reset |
490 # We get this one with pyodbc and SQL Server when connection was reset |
491 if exc.args[0] == '08S01' and session.mode != 'write': |
491 if exc.args[0] == '08S01' and session.mode != 'write': |
492 self.warning("trying to reconnect") |
492 self.warning("trying to reconnect") |
493 session.cnxset.reconnect(self) |
493 session.cnxset.reconnect() |
494 cursor = self.doexec(session, sql, args) |
494 cursor = self.doexec(session, sql, args) |
495 else: |
495 else: |
496 raise |
496 raise |
497 results = self.process_result(cursor, cbs, session=session) |
497 results = self.process_result(cursor, cbs, session=session) |
498 assert dbg_results(results) |
498 assert dbg_results(results) |
753 if res is not None: |
753 if res is not None: |
754 return res |
754 return res |
755 except (self.OperationalError, self.InterfaceError): |
755 except (self.OperationalError, self.InterfaceError): |
756 if session.mode == 'read' and _retry: |
756 if session.mode == 'read' and _retry: |
757 self.warning("trying to reconnect (eid_type_source())") |
757 self.warning("trying to reconnect (eid_type_source())") |
758 session.cnxset.reconnect(self) |
758 session.cnxset.reconnect() |
759 return self._eid_type_source(session, eid, sql, _retry=False) |
759 return self._eid_type_source(session, eid, sql, _retry=False) |
760 except Exception: |
760 except Exception: |
761 assert session.cnxset, 'session has no connections set' |
761 assert session.cnxset, 'session has no connections set' |
762 self.exception('failed to query entities table for eid %s', eid) |
762 self.exception('failed to query entities table for eid %s', eid) |
763 raise UnknownEid(eid) |
763 raise UnknownEid(eid) |