From f74add7de554614ea5f64c44039eff53d5d37a89 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Fri, 26 May 2017 09:12:06 -0400 Subject: [PATCH] Fix removeCompletedRequests for dict iteration Let's not iterate on a dict that we may actively modify within the iteration. Change-Id: I8d04df0504167ceda21aaca68a6115049dd53f01 --- nodepool/launcher.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nodepool/launcher.py b/nodepool/launcher.py index 3f1b57b..2ca1fb4 100644 --- a/nodepool/launcher.py +++ b/nodepool/launcher.py @@ -1452,7 +1452,12 @@ class NodePool(threading.Thread): We also must reset the allocated_to attribute for each Node assigned to our request, since we are deleting the request. ''' - for label in self._submittedRequests.keys(): + + # Use a copy of the labels because we modify _submittedRequests + # within the loop below. + requested_labels = list(self._submittedRequests.keys()) + + for label in requested_labels: label_requests = self._submittedRequests[label] active_requests = []