diff --git a/pyluos/io/serial_io.py b/pyluos/io/serial_io.py index 691f275..3baccc1 100644 --- a/pyluos/io/serial_io.py +++ b/pyluos/io/serial_io.py @@ -121,10 +121,6 @@ def extract_line(s): while self._running: to_read = self._serial.in_waiting - if to_read == 0: - time.sleep(self.period) - continue - s = self._serial.read(to_read) buff = buff + s diff --git a/pyluos/io/ws.py b/pyluos/io/ws.py index b1cd29f..e5dd4a4 100644 --- a/pyluos/io/ws.py +++ b/pyluos/io/ws.py @@ -63,7 +63,7 @@ def is_ready(self): def recv(self): try: - data = self._msg.get(True, 1) + data = self._msg.get(block = False) except queue.Empty: data = None return data @@ -73,7 +73,7 @@ def write(self, data): def close(self): self._running = False - self._poll_loop.join() + self._poll_loop.join(timeout = 1) self._ws.close() def _poll(self): @@ -94,6 +94,8 @@ def extract_line(s): while self._running: s = self._ws.recv() + if isinstance(s, str): + return buff = buff + s while self._running: line, buff = extract_line(buff)