diff --git a/session_db/pg_session_store.py b/session_db/pg_session_store.py index 1a6e3a2d4..849e431de 100644 --- a/session_db/pg_session_store.py +++ b/session_db/pg_session_store.py @@ -69,13 +69,13 @@ class PGSessionStore(sessions.SessionStore): @with_lock def _open_connection(self): - try: - # return cursor to the pool - if self._cr is not None: + # return cursor to the pool + if self._cr is not None: + try: self._cr.close() - self._cr = None - except Exception: # pylint: disable=except-pass - pass + except Exception: # pylint: disable=except-pass + pass + self._cr = None cnx = odoo.sql_db.db_connect(self._uri, allow_uri=True) self._cr = cnx.cursor() self._cr._cnx.autocommit = True