]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
apply list() around weakkeydictionary iteration
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Jul 2021 14:36:53 +0000 (10:36 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Jul 2021 14:37:52 +0000 (10:37 -0400)
Fixed an issue where clearing of mappers during things like test suite
teardowns could cause a "dictionary changed size" warning during garbage
collection, due to iteration of a weak-referencing dictionary. A ``list()``
has been applied to prevent concurrent GC from affecting this operation.

Fixes: #6771
Change-Id: I3e1d67e978b2726a282d8b327457f2d4b239a0c6

doc/build/changelog/unreleased_14/6771.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_api.py

diff --git a/doc/build/changelog/unreleased_14/6771.rst b/doc/build/changelog/unreleased_14/6771.rst
new file mode 100644 (file)
index 0000000..811ee7d
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+    :tags: orm, bug
+    :tickets: 6771
+
+    Fixed an issue where clearing of mappers during things like test suite
+    teardowns could cause a "dictionary changed size" warning during garbage
+    collection, due to iteration of a weak-referencing dictionary. A ``list()``
+    has been applied to prevent concurrent GC from affecting this operation.
index 54e927ee470a0e9950478dc7a73b1d2509c1ab5b..23b89a5434b0fe0d48ab384dde458e0df3ee5edc 100644 (file)
@@ -624,14 +624,14 @@ class registry(object):
         return itertools.chain(
             (
                 manager.mapper
-                for manager in self._managers
+                for manager in list(self._managers)
                 if manager.is_mapped
                 and not manager.mapper.configured
                 and manager.mapper._ready_for_configure
             ),
             (
                 npm
-                for npm in self._non_primary_mappers
+                for npm in list(self._non_primary_mappers)
                 if not npm.configured and npm._ready_for_configure
             ),
         )