rfc2217: improve read timeout implementation
- fix that total time is checked, not per byte
diff --git a/serial/rfc2217.py b/serial/rfc2217.py
index 52e7161..a8bb006 100644
--- a/serial/rfc2217.py
+++ b/serial/rfc2217.py
@@ -609,10 +609,13 @@
raise portNotOpenError
data = bytearray()
try:
+ timeout = Timeout(self._timeout)
while len(data) < size:
if self._thread is None:
raise SerialException('connection failed (reader thread died)')
- data += self._read_buffer.get(True, self._timeout)
+ data += self._read_buffer.get(True, timeout.time_left())
+ if timeout.expired():
+ break
except Queue.Empty: # -> timeout
pass
return bytes(data)