Close connection when listing or testing PostgreSQL databases

Closes #13441
(grafted from 18a811563d659b025b09973157f9d90a7dea8e6f)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier
2024-08-07 17:49:10 +02:00
parent f5f0cdc09b
commit 51f080555b
@@ -346,7 +346,7 @@ class Database(DatabaseInterface):
'Test failed for "%s"', db_name, exc_info=True)
continue
finally:
self.put_connection(connection)
self.put_connection(connection, close=True)
self.__class__._list_cache[hostname] = res
self.__class__._list_cache_timestamp[hostname] = now
@@ -391,7 +391,7 @@ class Database(DatabaseInterface):
try:
return self._test(connection, hostname=hostname)
finally:
self.put_connection(connection)
self.put_connection(connection, close=True)
@classmethod
def _test(cls, connection, hostname=None):