Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions ZPsycopgDA/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import psycopg2
from psycopg2.extensions import INTEGER, LONGINTEGER, BOOLEAN, DATE, TIME
from psycopg2.extensions import TransactionRollbackError, register_type
from psycopg2.extensions import QueryCanceledError
from psycopg2 import NUMBER, STRING, ROWID, DATETIME


Expand Down Expand Up @@ -162,7 +163,7 @@ def columns(self, table_name):

def query(self, query_string, max_rows=None, query_data=None):
self._register()
self.calls = self.calls+1
self.calls = self.calls + 1

desc = ()
res = []
Expand All @@ -178,16 +179,27 @@ def query(self, query_string, max_rows=None, query_data=None):
else:
c.execute(qs)
except TransactionRollbackError:
# Ha, here we have to look like we are the ZODB raising conflict errrors, raising ZPublisher.Publish.Retry just doesn't work
#logging.debug("Serialization Error, retrying transaction", exc_info=True)
raise ConflictError("TransactionRollbackError from psycopg2")
# Ha, here we have to look like we are the ZODB raising
# conflict errrors, raising ZPublisher.Publish.Retry just
# doesn't work
# logging.debug(
# "Serialization Error, retrying transaction",
# exc_info=True)
raise ConflictError(
"TransactionRollbackError from psycopg2")
except QueryCanceledError:
raise StandardError(
"canceling statement due to statement timeout")
except psycopg2.OperationalError:
#logging.exception("Operational error on connection, closing it.")
# logging.exception(
# "Operational error on connection, closing it.")
try:
# Only close our connection
self.putconn(True)
except:
#logging.debug("Something went wrong when we tried to close the pool", exc_info=True)
# logging.debug(
# "Something went wrong when we tried to close the"
# " pool", exc_info=True)
pass
if c.description is not None:
nselects += 1
Expand Down