Merge PR #2531 into 16.0

Signed-off-by sbidoul
pull/2550/head
OCA-git-bot 2023-01-23 13:32:31 +00:00
commit d2b26a09be
1 changed files with 8 additions and 1 deletions

View File

@ -23,7 +23,7 @@ def with_cursor(func):
tries += 1
try:
return func(self, *args, **kwargs)
except psycopg2.InterfaceError as e:
except (psycopg2.InterfaceError, psycopg2.OperationalError) as e:
_logger.info("Session in DB connection Retry %s/5" % tries)
if tries > 4:
raise e
@ -49,6 +49,13 @@ class PGSessionStore(sessions.SessionStore):
def _open_connection(self):
cnx = odoo.sql_db.db_connect(self._uri, allow_uri=True)
try:
# return cursor to the pool
if self._cr is not None:
self._cr.close()
self._cr = None
except Exception: # pylint: disable=except-pass
pass
self._cr = cnx.cursor()
self._cr._cnx.autocommit = True