changeset d75b372f72aa in trytond:5.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=d75b372f72aa
description:
Close connection after testing the database
issue9629
review302191002
(grafted from b5a1b101ef8b451a0a805450348ff01263bcaa8d)
diffstat:
trytond/backend/postgresql/database.py | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (21 lines):
diff -r 11c68bb6a9a6 -r d75b372f72aa trytond/backend/postgresql/database.py
--- a/trytond/backend/postgresql/database.py Sat Oct 03 00:29:16 2020 +0200
+++ b/trytond/backend/postgresql/database.py Thu Sep 24 23:02:14 2020 +0200
@@ -262,10 +262,13 @@
res = []
for db_name, in cursor:
try:
- with connect(**self._connection_params(db_name)
- ) as conn:
- if self._test(conn, hostname=hostname):
- res.append(db_name)
+ conn = connect(**self._connection_params(db_name))
+ try:
+ with conn:
+ if self._test(conn, hostname=hostname):
+ res.append(db_name)
+ finally:
+ conn.close()
except Exception:
continue
finally: