From c37f12834e2df7d3f89db077b0e1b21a565640dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 27 Aug 2018 10:43:08 +0200 Subject: [PATCH] Use a copied list to iterate on databases The close method pop the database from the list during the iteration which will change the size of the dict. issue7639 review70331002 --- trytond/backend/postgresql/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/backend/postgresql/database.py b/trytond/backend/postgresql/database.py index 7051161620..710566edb9 100644 --- a/trytond/backend/postgresql/database.py +++ b/trytond/backend/postgresql/database.py @@ -103,7 +103,7 @@ class Database(DatabaseInterface): def __new__(cls, name='template1'): with cls._lock: now = datetime.now() - for database in cls._databases.values(): + for database in list(cls._databases.values()): if ((now - database._last_use).total_seconds() > _timeout and database.name != name and not database._connpool._used):