changeset bb7f9931eac2 in trytond:5.0
details: https://hg.tryton.org/trytond?cmd=changeset;node=bb7f9931eac2
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 82a6b3d0f2a2 -r bb7f9931eac2 trytond/backend/postgresql/database.py
--- a/trytond/backend/postgresql/database.py    Sat Oct 03 00:31:01 2020 +0200
+++ b/trytond/backend/postgresql/database.py    Thu Sep 24 23:02:14 2020 +0200
@@ -219,10 +219,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:

Reply via email to