fix to be runnable with prctl module in Python3

This commit is contained in:
Kashiko Koibumi 2024-06-03 19:34:32 +09:00
parent 13aa12c09d
commit 4041fefe13
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4

View File

@ -14,6 +14,7 @@ There are also other threads in the `.network` package.
""" """
import threading import threading
import six
from class_addressGenerator import addressGenerator from class_addressGenerator import addressGenerator
from class_objectProcessor import objectProcessor from class_objectProcessor import objectProcessor
@ -32,12 +33,13 @@ else:
"""Set the thread name for external use (visible from the OS).""" """Set the thread name for external use (visible from the OS)."""
prctl.set_name(name) prctl.set_name(name)
def _thread_name_hack(self): if six.PY2:
set_thread_name(self.name) def _thread_name_hack(self):
threading.Thread.__bootstrap_original__(self) set_thread_name(self.name)
# pylint: disable=protected-access threading.Thread.__bootstrap_original__(self)
threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap # pylint: disable=protected-access
threading.Thread._Thread__bootstrap = _thread_name_hack threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap
threading.Thread._Thread__bootstrap = _thread_name_hack
printLock = threading.Lock() printLock = threading.Lock()