Skip to content

Commit 89b9f10

Browse files
committed
Fix hangup on reading of closed socket
We cannot get more date on closed socket, return what we have, if anythink
1 parent a0e9562 commit 89b9f10

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

+6
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,12 @@ def recv_into(self, buffer: bytearray, nbytes: int = 0, flags: int = 0) -> int:
594594
elif num_read > 0:
595595
# We got a message, but there are no more bytes to read, so we can stop.
596596
break
597+
elif self._status in (
598+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSED,
599+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSE_WAIT,
600+
):
601+
# No bytes to read and we will not get more, stop.
602+
break
597603
# No bytes yet, or more bytes requested.
598604
if self._timeout > 0 and time.monotonic() - last_read_time > self._timeout:
599605
raise timeout("timed out")

0 commit comments

Comments
 (0)