Use the list of sources instead of an iterator in update-feeds looping task stable
authorDenis Laxalde <denis.laxalde@logilab.fr>
Fri, 20 Sep 2013 15:42:04 +0200
branchstable
changeset 9263 42cc70a1b6ac
parent 9262 7fc54e02291f
child 9264 5668d210e49c
Use the list of sources instead of an iterator in update-feeds looping task This prevents RuntimeError due to dictionary size change that may occur (as a result of a new source being added) during iteration. Closes #3155843.
hooks/__init__.py
--- a/hooks/__init__.py	Tue Oct 08 16:10:42 2013 +0200
+++ b/hooks/__init__.py	Fri Sep 20 15:42:04 2013 +0200
@@ -59,7 +59,9 @@
         def update_feeds(repo):
             # don't iter on repo.sources which doesn't include copy based
             # sources (the one we're looking for)
-            for source in repo.sources_by_eid.itervalues():
+            # take a list to avoid iterating on a dictionary which size may
+            # change
+            for source in list(repo.sources_by_eid.values()):
                 if (not source.copy_based_source
                     or not repo.config.source_enabled(source)
                     or not source.config['synchronize']):