[PATCH] Don't try to iterate over threads directly in wait_all.
Chris Lumens
clumens at redhat.com
Wed Jul 8 15:06:58 UTC 2015
Someone may add or remove a thread mid-iteration, which causes a RuntimeError.
Instead, grab a copy of all the thread names and then iterate over that.
---
pyanaconda/threads.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/threads.py b/pyanaconda/threads.py
index 8f52260..1e8082f 100644
--- a/pyanaconda/threads.py
+++ b/pyanaconda/threads.py
@@ -120,7 +120,12 @@ class ThreadManager(object):
def wait_all(self):
"""Wait for all threads to exit and if there was an error re-raise it.
"""
- for name in self._objs.keys():
+ names = []
+
+ with self._objs_lock:
+ names = self._objs.keys()
+
+ for name in names:
if self.get(name) == threading.current_thread():
continue
log.debug("Waiting for thread %s to exit", name)
--
2.4.3
More information about the anaconda-patches
mailing list