From 8f6bb7b45d1cb343ed4e4d9da64cf8d6537cb70f Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Sat, 10 Dec 2016 18:22:05 +0100 Subject: [PATCH] [core/input] Remove "valid input required" logic from input Accidentially committed a experimental way to enforce waiting for a valid input, mainly for testing. see #23 --- bumblebee/input.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/bumblebee/input.py b/bumblebee/input.py index 6876031..a501a85 100644 --- a/bumblebee/input.py +++ b/bumblebee/input.py @@ -28,12 +28,10 @@ def read_input(inp): try: event = json.loads(line) inp.callback(event) - inp.has_valid_event = True inp.redraw() except ValueError: pass inp.has_event = True - inp.has_valid_event = True inp.clean_exit = True class I3BarInput(object): @@ -44,15 +42,12 @@ class I3BarInput(object): self.clean_exit = False self.global_id = str(uuid.uuid4()) self.need_event = False - self.need_valid_event = False self.has_event = False - self.has_valid_event = False self._condition = threading.Condition() def start(self): """Start asynchronous input processing""" self.has_event = False - self.has_valid_event = False self.running = True self._condition.acquire() self._thread = threading.Thread(target=read_input, args=(self,)) @@ -70,20 +65,16 @@ class I3BarInput(object): def wait(self, timeout): self._condition.wait(timeout) - def _wait(self, valid=False): + def _wait(self): while not self.has_event: time.sleep(0.1) - if valid: - while not self.has_valid_event: - time.sleep(0.1) self.has_event = False - self.has_valid_event = False def stop(self): """Stop asynchronous input processing""" self._condition.release() if self.need_event: - self._wait(self.need_valid_event) + self._wait() self.running = False self._thread.join() return self.clean_exit