Change in vdsm[master]: lib: pthread: allow to set system thread names
nsoffer at redhat.com
nsoffer at redhat.com
Thu May 21 23:43:25 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: lib: pthread: allow to set system thread names
......................................................................
Patch Set 8:
(3 comments)
Francesco, you missed some comments in version 6, I copied them to current version.
https://gerrit.ovirt.org/#/c/41052/8/tests/pthreadTests.py
File tests/pthreadTests.py:
Line 35: def test_name_is_set(self):
Line 36: NAME = "test-name"
Line 37: names = [None]
Line 38:
Line 39: def _helper():
We don't need private name for nested function, nobody can call it behind our back. Since this a thread target function, lets call it run().
Line 40: pthread.setname(NAME)
Line 41: names[0] = pthread.getname()
Line 42:
Line 43: th = threading.Thread(target=_helper)
Line 50: HELPER_NAME = "helper-name"
Line 51: orig_name = pthread.getname()
Line 52: stop = threading.Event()
Line 53:
Line 54: def _helper():
Same
Line 55: pthread.setname(HELPER_NAME)
Line 56: while not stop.is_set():
Line 57: # do not burn CPU
Line 58: time.sleep(.01)
Line 63:
Line 64: self.assertEqual(orig_name, pthread.getname())
Line 65:
Line 66: stop.set()
Line 67: th.join()
The synchronization is incorrect.
We should do:
ready = threading.Event()
done = threading.Event()
def run():
pthread.setname(HELPER_NAME)
ready.set()
done.wait()
threading.Thread(target=run).start()
ready.wait()
assert about names...
done.set()
There is no need to join the thread.
--
To view, visit https://gerrit.ovirt.org/41052
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib96bd0471a07449d2a0a0328137e8437aefad901
Gerrit-PatchSet: 8
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani 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