summaryrefslogtreecommitdiff
path: root/openerp/sql_db.py
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2013-02-15 12:37:51 +0100
committerOlivier Dony <odo@openerp.com>2013-02-15 12:37:51 +0100
commite464e1231d593cb147571e2e59c337d4667054eb (patch)
treed72c012fc9e09a2840b5f870df6176e7b8582cac /openerp/sql_db.py
parent94715ccbeceb94e6d08245ad234db4a653dbd677 (diff)
[FIX] sql_db: closing a closed connection is not allowed in psycopg2 2.4.4 and earlier
Having the connections automatically reaped by psycopg2 is not guaranteed to happen all the time, so we still need to take extra steps to forece-close them bzr revid: odo@openerp.com-20130215113751-12kwmfynyt43qs57
Diffstat (limited to 'openerp/sql_db.py')
-rw-r--r--openerp/sql_db.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/openerp/sql_db.py b/openerp/sql_db.py
index be15bdbdc6a..a41f5e5077e 100644
--- a/openerp/sql_db.py
+++ b/openerp/sql_db.py
@@ -404,7 +404,9 @@ class ConnectionPool(object):
cnx.reset()
except psycopg2.OperationalError:
self._debug('Cannot reset connection at index %d: %r', i, cnx.dsn)
- cnx.close()
+ # psycopg2 2.4.4 and earlier do not allow closing a closed connection
+ if cnx.closed:
+ cnx.close()
if cnx.closed:
self._connections.pop(i)