summaryrefslogtreecommitdiff
path: root/searx/unixthreadname.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-06-10 08:11:15 +0200
committerGitHub <noreply@github.com>2021-06-10 08:11:15 +0200
commit68df982e21b0f4440485dd690b9396ec34ab0cc0 (patch)
tree1e0a8584f325a63c05caefae83a55c0448f6ca6d /searx/unixthreadname.py
parent314e09091bc240b812b4fd2369c997432382f3cb (diff)
parent2a109d0a5fb55a5cc7f9d2efdda5c7389e5f172a (diff)
Merge pull request #135 from searxng/refactor-webapp
Refactor webapp
Diffstat (limited to 'searx/unixthreadname.py')
-rw-r--r--searx/unixthreadname.py20
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