Merge branch 'helper_threading_formating' of https://github.com/MahendraNG/PyBitmessage into helper_threading_formating
This commit is contained in:
commit
a836d0a9af
|
@ -1,9 +1,14 @@
|
|||
"""Helper threading perform all the threading operations."""
|
||||
|
||||
from contextlib import contextmanager
|
||||
import threading
|
||||
|
||||
try:
|
||||
import prctl
|
||||
def set_thread_name(name): prctl.set_name(name)
|
||||
|
||||
def set_thread_name(name):
|
||||
"""Set a name for the thread for python internal use."""
|
||||
prctl.set_name(name)
|
||||
|
||||
def _thread_name_hack(self):
|
||||
set_thread_name(self.name)
|
||||
|
@ -12,17 +17,21 @@ try:
|
|||
threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap
|
||||
threading.Thread._Thread__bootstrap = _thread_name_hack
|
||||
except ImportError:
|
||||
def set_thread_name(name): threading.current_thread().name = name
|
||||
def set_thread_name(name):
|
||||
"""Set the thread name for external use (visible from the OS)."""
|
||||
threading.current_thread().name = name
|
||||
|
||||
|
||||
class StoppableThread(object):
|
||||
def initStop(self):
|
||||
self.stop = threading.Event()
|
||||
self._stopped = False
|
||||
|
||||
|
||||
def stopThread(self):
|
||||
self._stopped = True
|
||||
self.stop.set()
|
||||
|
||||
|
||||
class BusyError(threading.ThreadError):
|
||||
pass
|
||||
|
||||
|
|
Reference in New Issue
Block a user