Skip to content

Commit

Permalink
Merge pull request #235 from dhalbert/socket-send-non-int
Browse files Browse the repository at this point in the history
Handle ESP32SPI Socket.send(), which does not return a byte count
  • Loading branch information
dhalbert authored Jan 5, 2025
2 parents cac3b41 + b47ed70 commit a15e711
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adafruit_minimqtt/adafruit_minimqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ def _send_bytes(
view = memoryview(buffer)
while bytes_sent < bytes_to_send:
try:
bytes_sent += self._sock.send(view[bytes_sent:])
sent_now = self._sock.send(view[bytes_sent:])
# Some versions of `Socket.send()` do not return the number of bytes sent.
if not isinstance(sent_now, int):
return
bytes_sent += sent_now
except OSError as exc:
if exc.errno == errno.EAGAIN:
continue
Expand Down

0 comments on commit a15e711

Please sign in to comment.