Change in vdsm[master]: Adding threads limitation to misc.tmap
zhshzhou at linux.vnet.ibm.com
zhshzhou at linux.vnet.ibm.com
Tue Oct 30 08:04:03 UTC 2012
Zhou Zheng Sheng has posted comments on this change.
Change subject: Adding threads limitation to misc.tmap
......................................................................
Patch Set 2: I would prefer that you didn't submit this
(3 inline comments)
....................................................
File vdsm/storage/misc.py
Line 1227: if maxthreads < 1 and maxthreads != UNLIMITED_THREADS:
Line 1228: raise ValueError("Wrong input passed to function tmap: %s", maxthreads)
Line 1229:
Line 1230: resultsDict = {}
Line 1231: error = [None]
List is used here mainly because itself is thread-safe. Do I get your idea, Yaniv? If yes, a comment can be added here for explanation.
Line 1232:
Line 1233: def wrapper(f, arg, index):
Line 1234: try:
Line 1235: resultsDict[index] = f(arg)
Line 1252: if threadsQueue.full():
Line 1253: # Wait for the first unfinished thread in list to finish if we
Line 1254: # have already initiate all possible thread's slots (maxthreads)
Line 1255: if threadsQueue.empty():
Line 1256: raise RuntimeError("Queue is empty")
I notice that threadsQueue is accessed only by the current thread, it's not possible to be full() and empty() at the same time. Why do you add this check?
Line 1257: else:
Line 1258: threadsQueue.get_nowait().join()
Line 1259: t = threading.Thread(target=wrapper, args=(func, arg, i))
Line 1260: threadsQueue.put_nowait(t)
Line 1267: for i, result in resultsDict.iteritems():
Line 1268: results[i] = result
Line 1269:
Line 1270: if error[0] is not None:
Line 1271: raise error[0]
Maybe you can exchange the order of code snippet in line 1270-1271 with line 1266-1268.
Line 1272:
Line 1273: return tuple(results)
Line 1274:
Line 1275:
--
To view, visit http://gerrit.ovirt.org/8858
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I07845bfd78b9215e8994ac2ebe46a7ff78c85625
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Shu Ming <shuming at linux.vnet.ibm.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list