changeset bd815fbc3442 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset;node=bd815fbc3442
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 ab05701a8c20 -r bd815fbc3442 trytond/backend/postgresql/database.py
--- a/trytond/backend/postgresql/database.py    Sat Oct 03 00:27:49 2020 +0200
+++ b/trytond/backend/postgresql/database.py    Thu Sep 24 23:02:14 2020 +0200
@@ -280,10 +280,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:
                     logger.debug(
                         'Test failed for "%s"', db_name, exc_info=True)

Reply via email to