From 0c110b9debf48cc2876ea35c42ac7676f287a070 Mon Sep 17 00:00:00 2001 From: Kashiko Koibumi Date: Mon, 3 Jun 2024 19:34:32 +0900 Subject: [PATCH] fix to be runnable with prctl module in Python3 --- src/threads.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/threads.py b/src/threads.py index ac8bf7a6..ce781a77 100644 --- a/src/threads.py +++ b/src/threads.py @@ -14,6 +14,7 @@ There are also other threads in the `.network` package. """ import threading +import six from class_addressGenerator import addressGenerator from class_objectProcessor import objectProcessor @@ -32,12 +33,13 @@ else: """Set the thread name for external use (visible from the OS).""" prctl.set_name(name) - def _thread_name_hack(self): - set_thread_name(self.name) - threading.Thread.__bootstrap_original__(self) - # pylint: disable=protected-access - threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap - threading.Thread._Thread__bootstrap = _thread_name_hack + if six.PY2: + def _thread_name_hack(self): + set_thread_name(self.name) + threading.Thread.__bootstrap_original__(self) + # pylint: disable=protected-access + threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap + threading.Thread._Thread__bootstrap = _thread_name_hack printLock = threading.Lock()