Skip to content

Commit

Permalink
Merge pull request #198 from BHAY-3DiTex/fix/polling
Browse files Browse the repository at this point in the history
Fix polling limitation to send messages
  • Loading branch information
nicolas-rabault authored Dec 12, 2024
2 parents 9001272 + ad423bc commit 044a1ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pyluos/io/serial_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions pyluos/io/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 044a1ae

Please sign in to comment.