changeset b5a1b101ef8b in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=b5a1b101ef8b
description:
        Close connection after testing the database

        issue9629
        review302191002
diffstat:

 trytond/backend/postgresql/database.py |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (21 lines):

diff -r e5c0935843f6 -r b5a1b101ef8b trytond/backend/postgresql/database.py
--- a/trytond/backend/postgresql/database.py    Thu Sep 24 23:00:52 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