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
This commit is contained in:
1 parent
5a7aca31ea
commit
c37f12834e
1 file changed
+1
-1
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user