Hello Milan Zamazal,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/61770

to review the following change.

Change subject: virt: Fix of Executor._active_workers crash on modification
......................................................................

virt: Fix of Executor._active_workers crash on modification

Executor._active_workers doesn't use a lock when accessing
self._workers.  This is intentional, since we access self._workers
read-only, we don't need exact value for some snapshot of the executor
state and we have no reason to impose locking on the method.

However, we still must be careful, because we loop over the value.  If
it gets modified during the loop then

  RuntimeError: Set changed size during iteration

is raised.  This patch prevents that error by making a shallow copy of
self._workers in the loop.

Change-Id: Iaed995109e98c5ab79724a4765c3212140ebebb7
Signed-off-by: Milan Zamazal <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/61690
Continuous-Integration: Jenkins CI
Reviewed-by: Francesco Romani <[email protected]>
---
M lib/vdsm/executor.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/61770/1

diff --git a/lib/vdsm/executor.py b/lib/vdsm/executor.py
index 7ad6611..1bfb23f 100644
--- a/lib/vdsm/executor.py
+++ b/lib/vdsm/executor.py
@@ -106,7 +106,7 @@
 
     @property
     def _active_workers(self):
-        return len([w for w in self._workers if not w.discarded])
+        return len([w for w in tuple(self._workers) if not w.discarded])
 
     @property
     def _total_workers(self):


-- 
To view, visit https://gerrit.ovirt.org/61770
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaed995109e98c5ab79724a4765c3212140ebebb7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <[email protected]>
Gerrit-Reviewer: Milan Zamazal <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to