diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2013-07-06 08:31:43 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2013-07-29 12:01:00 -0700 |
commit | 3ca45c9a00f14f2410fcc5fac92d205b0abdb688 (patch) | |
tree | 5060e9f749891cbc02a8e627c19885ce6fb41eac /framework | |
parent | 0486e933397379e4b35dd442b69feccfe3b2482c (diff) |
threads.py: PEP8 compliance
Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/threads.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/framework/threads.py b/framework/threads.py index 71e9b43f8..fcc266e3a 100644 --- a/framework/threads.py +++ b/framework/threads.py @@ -21,16 +21,18 @@ # IN THE SOFTWARE. # +from weakref import WeakKeyDictionary +import multiprocessing + from threadpool import ThreadPool, WorkRequest from patterns import Singleton from threading import RLock -from weakref import WeakKeyDictionary -import multiprocessing + def synchronized_self(function): ''' - A decorator function for providing multithreaded, synchronized access - amongst one or more functions within a class instance. + A decorator function for providing multithreaded, synchronized access + amongst one or more functions within a class instance. ''' def wrapper(self, *args, **kwargs): synchronized_self.locks.setdefault(self, RLock()).acquire() @@ -40,7 +42,10 @@ def synchronized_self(function): synchronized_self.locks[self].release() return wrapper -synchronized_self.locks = WeakKeyDictionary() # track the locks for each instance + +# track the locks for each instance +synchronized_self.locks = WeakKeyDictionary() + class ConcurrentTestPool(Singleton): @synchronized_self @@ -48,12 +53,8 @@ class ConcurrentTestPool(Singleton): self.pool = ThreadPool(multiprocessing.cpu_count()) @synchronized_self - def put(self, callable_, args = None, kwds = None): - self.pool.putRequest( - WorkRequest( - callable_, args = args, kwds = kwds - ) - ) + def put(self, callable_, args=None, kwds=None): + self.pool.putRequest(WorkRequest(callable_, args=args, kwds=kwds)) def join(self): self.pool.wait() |