Change in vdsm[master]: concurrent: Add Barrier class
ibarkan at redhat.com
ibarkan at redhat.com
Mon Jul 27 07:57:18 UTC 2015
Ido Barkan has posted comments on this change.
Change subject: concurrent: Add Barrier class
......................................................................
Patch Set 11: Code-Review-1
(4 comments)
cool.
-1 just for visibility. mostly nits.
https://gerrit.ovirt.org/#/c/42927/11/lib/vdsm/concurrent.py
File lib/vdsm/concurrent.py:
Line 57:
Line 58: for i in range(4):
Line 59: threading.Thread(target=thread).start()
Line 60:
Line 61: # Will block until all 4 threads are blocked on wait(), waking up all
5
Line 62: # threads blocked on the barrier.
Line 63: barrier.wait()
Line 64:
Line 65: """
Line 73: if count < 1:
Line 74: raise ValueError("Invalid count %d (expecting count >= 1)" % count)
Line 75: self._count = count
Line 76: self._waiting = 0
Line 77: self._closed = True
IMO using '_open' is clearer.
Line 78: self._cond = threading.Condition(threading.Lock())
Line 79:
Line 80: def wait(self, timeout=None):
Line 81: """
https://gerrit.ovirt.org/#/c/42927/11/tests/concurrentTests.py
File tests/concurrentTests.py:
Line 60: barrier.wait(0)
Line 61: t.join()
Line 62:
Line 63: @slowtest
Line 64: def test_wakup_blocked_thread(self):
wakeup
Line 65: barrier = concurrent.Barrier(2)
Line 66: done = threading.Event()
Line 67:
Line 68: def waiter():
Line 65: barrier = concurrent.Barrier(2)
Line 66: done = threading.Event()
Line 67:
Line 68: def waiter():
Line 69: barrier.wait(2)
when calling wait, explicitly name timeout=N. it is more readable.
Line 70: done.set()
Line 71:
Line 72: t = threading.Thread(target=waiter)
Line 73: t.daemon = True
--
To view, visit https://gerrit.ovirt.org/42927
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I68525e18f6b3774d7e10af1226a7bc3404c68ae9
Gerrit-PatchSet: 11
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Ala Hino <ahino at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Dima Kuznetsov <dkuznets at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list