summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-06-01 14:32:09 +0000
committerGerrit Code Review <review@openstack.org>2016-06-01 14:32:09 +0000
commit3fb6b1c5a1519a47221ec60c145b7a5bdfe5a3a3 (patch)
treea72662566747a8a3ac67f5ff2f82e9671070c699
parent812d1bc1d042270e461bc5df09a4abdf8f490589 (diff)
parent46fcc461b6d50b0be42754ac1801b16002f76c94 (diff)
downloadgear-3fb6b1c5a1519a47221ec60c145b7a5bdfe5a3a3.tar.gz
Merge "Do not change object size when iterating"
-rw-r--r--gear/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/gear/__init__.py b/gear/__init__.py
index 7fccc34..c561a86 100644
--- a/gear/__init__.py
+++ b/gear/__init__.py
@@ -797,7 +797,11 @@ class BaseClientServer(object):
self.log.debug("Marking %s as disconnected" % conn)
self.connections_condition.acquire()
try:
- jobs = conn.related_jobs.values()
+ # NOTE(notmorgan): In the loop below it is possible to change the
+ # jobs list on the connection. In python 3 .values() is an iter not
+ # a static list, meaning that a change will break the for loop
+ # as the object being iterated on will have changed in size.
+ jobs = list(conn.related_jobs.values())
if conn in self.active_connections:
self.active_connections.remove(conn)
if conn not in self.inactive_connections:
@@ -2683,7 +2687,11 @@ class Server(BaseClientServer):
self.connections_condition.acquire()
self._unregisterConnection(conn)
try:
- jobs = conn.related_jobs.values()
+ # NOTE(notmorgan): In the loop below it is possible to change the
+ # jobs list on the connection. In python 3 .values() is an iter not
+ # a static list, meaning that a change will break the for loop
+ # as the object being iterated on will have changed in size.
+ jobs = list(conn.related_jobs.values())
if conn in self.active_connections:
self.active_connections.remove(conn)
finally: