From e6e4c66010271c0056c5b841d6f621a97ef20125 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Sat, 7 Apr 2018 15:14:43 +0530 Subject: [PATCH 1/3] helper_threading formating --- src/helper_threading.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/helper_threading.py b/src/helper_threading.py index 3b7ba378..2f8d2921 100644 --- a/src/helper_threading.py +++ b/src/helper_threading.py @@ -1,9 +1,13 @@ +"""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): + prctl.set_name(name) def _thread_name_hack(self): set_thread_name(self.name) @@ -12,17 +16,20 @@ 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): + 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 From 5efb4913491155a84895a480e871df04b174edfe Mon Sep 17 00:00:00 2001 From: Mahendra Date: Sat, 7 Apr 2018 18:42:21 +0530 Subject: [PATCH 2/3] add docstring for set_thread methrod in helper_msgcoding --- src/helper_threading.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/helper_threading.py b/src/helper_threading.py index 2f8d2921..102c2cc0 100644 --- a/src/helper_threading.py +++ b/src/helper_threading.py @@ -7,6 +7,7 @@ try: import prctl def set_thread_name(name): + """Set a name for the thread for python internal use.""" prctl.set_name(name) def _thread_name_hack(self): @@ -17,6 +18,7 @@ try: threading.Thread._Thread__bootstrap = _thread_name_hack except ImportError: def set_thread_name(name): + """Set the thread name for external use (visible from the OS).""" threading.current_thread().name = name From d81fb4b63e286a29d5f08d9544dc5b1695cdd0fe Mon Sep 17 00:00:00 2001 From: Mahendra Garg Date: Tue, 10 Apr 2018 14:19:34 +0530 Subject: [PATCH 3/3] Made changes while import prctl --- src/helper_threading.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/helper_threading.py b/src/helper_threading.py index 102c2cc0..6b6a5e25 100644 --- a/src/helper_threading.py +++ b/src/helper_threading.py @@ -5,7 +5,11 @@ import threading try: import prctl - +except ImportError: + def set_thread_name(name): + """Set the thread name for external use (visible from the OS).""" + threading.current_thread().name = name +else: def set_thread_name(name): """Set a name for the thread for python internal use.""" prctl.set_name(name) @@ -16,10 +20,6 @@ try: threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap threading.Thread._Thread__bootstrap = _thread_name_hack -except ImportError: - def set_thread_name(name): - """Set the thread name for external use (visible from the OS).""" - threading.current_thread().name = name class StoppableThread(object):