Close connection after testing the database

issue9629
review302191002
This commit is contained in:
Cédric Krier committed 2020-09-24 23:02:14 +02:00
1 parent 81bade4035
commit 99135bf9db
1 file changed
+7 -4
+7 -4
View File
@@ -280,10 +280,13 @@ class Database(DatabaseInterface):
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)