Francesco Romani has posted comments on this change. Change subject: lib: allow to set system thread names ......................................................................
Patch Set 1: (4 comments) this patch lacks tests. Let's just see if the API is good enough or if we want something different (e.g. monkey patching?) Once the API is settled I'll start use it for all the thread. Let's not forget that MOM is using a large amount of thread *in the VDSM process*, but we can't name them (without ugly hacks or monkeypatching) https://gerrit.ovirt.org/#/c/41052/1/lib/vdsm/threadname.py File lib/vdsm/threadname.py: Line 22: import functools Line 23: import threading Line 24: Line 25: Line 26: LIBPTHREAD = ctypes.CDLL("libpthread.so.0", use_errno=True) I think we can assume this library is always present Line 27: Line 28: _pthread_setname_np_proto = ctypes.CFUNCTYPE(ctypes.c_int, Line 29: ctypes.c_void_p, Line 30: ctypes.c_char_p) Line 28: _pthread_setname_np_proto = ctypes.CFUNCTYPE(ctypes.c_int, Line 29: ctypes.c_void_p, Line 30: ctypes.c_char_p) Line 31: _pthread_setname_np = _pthread_setname_np_proto(('pthread_setname_np', Line 32: LIBPTHREAD)) ...but should we guard against (unlikely?) failures here? Line 33: Line 34: Line 35: def set_system_name(thread, name): Line 36: ident = getattr(thread, "ident", None) Line 34: Line 35: def set_system_name(thread, name): Line 36: ident = getattr(thread, "ident", None) Line 37: if ident is not None: Line 38: _pthread_setname_np(ident, name[:15]) this should just explode if _pthread_setname_np is not available for any reason Line 39: Line 40: Line 41: def systemname(name): Line 42: """ Line 37: if ident is not None: Line 38: _pthread_setname_np(ident, name[:15]) Line 39: Line 40: Line 41: def systemname(name): add protection here if for some obscure reason _pthread_setname_np is not present? I think the best option here is log a warning and go ahead Line 42: """ Line 43: Decorator to set set the system name for a thread body Line 44: callable Line 45: """ -- 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: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com> Gerrit-Reviewer: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer <nsof...@redhat.com> Gerrit-Reviewer: Yaniv Bronhaim <ybron...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches