diff --git a/i3pystatus/core/threading/manager.py b/i3pystatus/core/threading/manager.py index 1d91b98..37de489 100644 --- a/i3pystatus/core/threading/manager.py +++ b/i3pystatus/core/threading/manager.py @@ -14,7 +14,7 @@ class Manager: def __call__(self): separate = [] for thread in self.threads: - separate.extend(self.branch(thread, thread.time)) + separate.extend(thread.branch(thread.time, self.upper_bound)) self.create_threads(self.partition(separate)) def __repr__(self): @@ -23,12 +23,6 @@ class Manager: def wrap(self, workload): return wrapper.WorkloadWrapper(wrapper.ExceptionWrapper(workload)) - def branch(self, thread, vtime): - if len(thread) > 1 and vtime > self.upper_bound: - remove = thread.pop() - return [remove] + self.branch(thread, vtime - remove.time) - return [] - def partition(self, workloads): return partition(workloads, self.lower_bound, lambda workload: workload.time) diff --git a/i3pystatus/core/threading/threads.py b/i3pystatus/core/threading/threads.py index 28999f0..7718ff1 100644 --- a/i3pystatus/core/threading/threads.py +++ b/i3pystatus/core/threading/threads.py @@ -51,3 +51,9 @@ class Thread(threading.Thread): filltime = self.target_interval - self.time if filltime > 0: time.sleep(filltime) + + def branch(self, vtime, bound): + if len(self) > 1 and vtime > bound: + remove = self.pop() + return [remove] + self.branch(vtime - remove.time, bound) + return [] diff --git a/i3pystatus/core/threading/wrapper.py b/i3pystatus/core/threading/wrapper.py index 24b5716..08a1d30 100644 --- a/i3pystatus/core/threading/wrapper.py +++ b/i3pystatus/core/threading/wrapper.py @@ -16,7 +16,7 @@ class ExceptionWrapper(Wrapper): def __call__(self): try: self.workload() - except Exception as exc: + except BaseException as exc: sys.stderr.write("Exception in {thread}".format(thread=threading.current_thread().name)) traceback.print_exception(*sys.exc_info(), file=sys.stderr) sys.stderr.flush()