diff --git a/pyluos/io/serial_io.py b/pyluos/io/serial_io.py index 3baccc1..7a6fcfe 100644 --- a/pyluos/io/serial_io.py +++ b/pyluos/io/serial_io.py @@ -75,7 +75,7 @@ def write(self, data): def close(self): self._running = False - self._poll_loop.join() + self._poll_loop.join(timeout = 1) self._serial.close() @@ -121,6 +121,10 @@ 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 e5dd4a4..b2d93b8 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(block = False) + data = self._msg.get(True, 0.01) 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(timeout = 1) + self._poll_loop.join(timeout = 2) self._ws.close() def _poll(self):