diff options
author | Alexandre Flament <alex@al-f.net> | 2021-06-08 11:34:36 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-06-08 15:54:11 +0200 |
commit | 70bbd14b1ae122f2d1db7b8907d47394d549a149 (patch) | |
tree | d7b254afcb2e5b0d62f437221475d7f1a3c03f83 /searx/unixthreadname.py | |
parent | 0e23113f706aa3b123f93054e55bdf52e928a5b0 (diff) | |
download | searxng-70bbd14b1ae122f2d1db7b8907d47394d549a149.tar.gz searxng-70bbd14b1ae122f2d1db7b8907d47394d549a149.zip |
[mod] move hook to set Unix thread name into searx.unixthreadname
requires setproctitle (but optional)
Diffstat (limited to 'searx/unixthreadname.py')
-rw-r--r-- | searx/unixthreadname.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/searx/unixthreadname.py b/searx/unixthreadname.py new file mode 100644 index 000000000..9a6f53813 --- /dev/null +++ b/searx/unixthreadname.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# lint: pylint +""" +if setproctitle is installed. +set Unix thread name with the Python thread name +""" + +try: + import setproctitle +except ImportError: + pass +else: + import threading + old_thread_init = threading.Thread.__init__ + + def new_thread_init(self, *args, **kwargs): + # pylint: disable=protected-access, disable=c-extension-no-member, disable=missing-function-docstring + old_thread_init(self, *args, **kwargs) + setproctitle.setthreadtitle(self._name) + threading.Thread.__init__ = new_thread_init |