Skip to content

Commit dfaf68e

Browse files
committed
restore _send_bytes()
1 parent 269d10b commit dfaf68e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,21 @@ def connect( # noqa: PLR0913, too many arguments in function definition
464464
raise MMQTTException(exc_msg) from last_exception
465465
raise MMQTTException(exc_msg)
466466

467+
def _send_bytes(
468+
self,
469+
buffer: Union[bytes, bytearray, memoryview],
470+
):
471+
bytes_sent: int = 0
472+
bytes_to_send = len(buffer)
473+
view = memoryview(buffer)
474+
while bytes_sent < bytes_to_send:
475+
try:
476+
bytes_sent += self._sock.send(view[bytes_sent:])
477+
except OSError as exc:
478+
if exc.errno == EAGAIN:
479+
continue
480+
raise
481+
467482
def _connect( # noqa: PLR0912, PLR0913, PLR0915, Too many branches, Too many arguments, Too many statements
468483
self,
469484
clean_session: bool = True,

0 commit comments

Comments
 (0)