helper_threading formating
This commit is contained in:
parent
c5462a00cc
commit
e6e4c66010
|
@ -1,9 +1,13 @@
|
||||||
|
"""Helper threading perform all the threading operations."""
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import prctl
|
import prctl
|
||||||
def set_thread_name(name): prctl.set_name(name)
|
|
||||||
|
def set_thread_name(name):
|
||||||
|
prctl.set_name(name)
|
||||||
|
|
||||||
def _thread_name_hack(self):
|
def _thread_name_hack(self):
|
||||||
set_thread_name(self.name)
|
set_thread_name(self.name)
|
||||||
|
@ -12,7 +16,9 @@ try:
|
||||||
threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap
|
threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap
|
||||||
threading.Thread._Thread__bootstrap = _thread_name_hack
|
threading.Thread._Thread__bootstrap = _thread_name_hack
|
||||||
except ImportError:
|
except ImportError:
|
||||||
def set_thread_name(name): threading.current_thread().name = name
|
def set_thread_name(name):
|
||||||
|
threading.current_thread().name = name
|
||||||
|
|
||||||
|
|
||||||
class StoppableThread(object):
|
class StoppableThread(object):
|
||||||
def initStop(self):
|
def initStop(self):
|
||||||
|
@ -23,6 +29,7 @@ class StoppableThread(object):
|
||||||
self._stopped = True
|
self._stopped = True
|
||||||
self.stop.set()
|
self.stop.set()
|
||||||
|
|
||||||
|
|
||||||
class BusyError(threading.ThreadError):
|
class BusyError(threading.ThreadError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user