Change in vdsm[master]: lib: allow to set system thread names
fromani at redhat.com
fromani at redhat.com
Mon May 18 11:58:11 UTC 2015
Francesco Romani has posted comments on this change.
Change subject: lib: allow to set system thread names
......................................................................
Patch Set 2:
(5 comments)
https://gerrit.ovirt.org/#/c/41052/2/lib/vdsm/threadname.py
File lib/vdsm/threadname.py:
Line 32: try:
Line 33: _pthread_setname_np = _pthread_setname_np_proto(('pthread_setname_np',
Line 34: LIBPTHREAD))
Line 35: except AttributeError:
Line 36: _pthread_setname_np = None
> Lets log a warning *once* if pthread_setname_np is not available, and initi
will do.
Line 37:
Line 38:
Line 39: def set_system_name(thread, name):
Line 40: if _pthread_setname_np is None:
Line 41: raise RuntimeError("Cannot set system name for threads")
Line 42:
Line 43: ident = getattr(thread, "ident", None)
Line 44: if ident is None:
Line 45: raise RuntimeError("Cannot set system name on a thread without ident")
> Is this possible?
will double check, and drop if it is impossible. I'm probably being overzealous here.
Line 46:
Line 47: _pthread_setname_np(ident, name[:15])
Line 48:
Line 49:
Line 43: ident = getattr(thread, "ident", None)
Line 44: if ident is None:
Line 45: raise RuntimeError("Cannot set system name on a thread without ident")
Line 46:
Line 47: _pthread_setname_np(ident, name[:15])
> Taking only part of the name is bad api. We should raise ValueError if the
Will raise ValueError.
The limit is documented:
http://man7.org/linux/man-pages/man3/pthread_setname_np.3.html
"""
[...]
The thread name is a meaningful C language string, whose length is restricted to 16 characters, including the terminating null byte ('\0').
[...]
"""
Line 48:
Line 49:
Line 50: def systemname(name):
Line 51: """
Line 48:
Line 49:
Line 50: def systemname(name):
Line 51: """
Line 52: Decorator to set set the system name for a thread body callable.
> body is not common term, I think we should use f or func instead.
will rename to 'func', and post a followup patch showing some usage examples.
Line 53: The system name must be an ASCII string at most 15 characters long.
Line 54: """
Line 55: def decorator(func):
Line 56: @functools.wraps(func)
Line 57: def wrapper(*args, **kwargs):
Line 58: thread = threading.current_thread()
Line 59: try:
Line 60: set_system_name(thread, name)
Line 61: except RuntimeError:
I believe we should swallow silently ValueError here, right?
Line 62: pass
Line 63: return func(*args, **kwargs)
Line 64: return wrapper
--
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: 2
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