Change in vdsm[master]: lib: pthread: allow to set system thread names
nsoffer at redhat.com
nsoffer at redhat.com
Tue May 19 15:43:02 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: lib: pthread: allow to set system thread names
......................................................................
Patch Set 6:
(3 comments)
https://gerrit.ovirt.org/#/c/41052/6/lib/vdsm/pthread.py
File lib/vdsm/pthread.py:
Line 44: def setname(name):
Line 45: """
Line 46: Allows to set a system-wide thread name.
Line 47: This decorator should be used on `func' callables which implement
Line 48: a threading.Thread target.
This is not very clear, lets clarify and give an example:
This decorator should be used on a thread target function:
@pthread.setname("vdsm-cleanup")
def run():
...
Thread(target=run).start()
I wonder, since this one line we have to add to all threads functions, why not make it a regular function, and simply set the name from the function?
def run():
pthread.setname("vdsm-cleanup")
What is the advantage of the decorator version?
Line 49: The length of the name is limited to 15 bytes - see pthread_setname_np(3)
Line 50: The system name must be an ASCII string at most 15 characters long.
Line 51: """
Line 52: if len(name) > 15:
Line 46: Allows to set a system-wide thread name.
Line 47: This decorator should be used on `func' callables which implement
Line 48: a threading.Thread target.
Line 49: The length of the name is limited to 15 bytes - see pthread_setname_np(3)
Line 50: The system name must be an ASCII string at most 15 characters long.
Last 2 lines say the same thing, lets merge them:
The name is limited to 15 ASCII characters - see pthread_setname_np(3).
Line 51: """
Line 52: if len(name) > 15:
Line 53: raise ValueError("Expecting up to 15 bytes for the name")
Line 54:
Line 49: The length of the name is limited to 15 bytes - see pthread_setname_np(3)
Line 50: The system name must be an ASCII string at most 15 characters long.
Line 51: """
Line 52: if len(name) > 15:
Line 53: raise ValueError("Expecting up to 15 bytes for the name")
bytes is not a good term, lets use characters.
It would be also useful to accept only ascii by encoding the name to ascii:
name = name.encode("ascii")
This is what ctypes is doing internally, but if we do it here this will fail in import time instead of runtime.
Line 54:
Line 55: def decorator(func):
Line 56: @functools.wraps(func)
Line 57: def wrapper(*args, **kwargs):
--
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: 6
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