2021-06-08 09:34:36 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
"""
|
|
|
|
if setproctitle is installed.
|
|
|
|
set Unix thread name with the Python thread name
|
|
|
|
"""
|
|
|
|
|
|
|
|
try:
|
|
|
|
import setproctitle
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
import threading
|
2021-12-27 08:26:22 +00:00
|
|
|
|
2021-06-08 09:34:36 +00:00
|
|
|
old_thread_init = threading.Thread.__init__
|
|
|
|
|
|
|
|
def new_thread_init(self, *args, **kwargs):
|
2021-09-07 11:34:35 +00:00
|
|
|
# pylint: disable=protected-access, disable=c-extension-no-member
|
2021-06-08 09:34:36 +00:00
|
|
|
old_thread_init(self, *args, **kwargs)
|
|
|
|
setproctitle.setthreadtitle(self._name)
|
2021-12-27 08:26:22 +00:00
|
|
|
|
2021-06-08 09:34:36 +00:00
|
|
|
threading.Thread.__init__ = new_thread_init
|