pgsql: fix self._conn.close() being called without connection

If an error occurs on connection establishment, self._conn is None so it can't
be closed.

Change-Id: If6fce24cb27aa7090b5165ca4a895c846c40d2dd
This commit is contained in:
Julien Danjou 2017-06-22 12:48:06 +02:00
parent 413527c181
commit 90a56b0ab6
1 changed files with 2 additions and 1 deletions

View File

@ -146,7 +146,8 @@ class PostgresLock(locking.Lock):
try:
return _lock()
except Exception:
self._conn.close()
if self._conn:
self._conn.close()
raise
def release(self):