Skip to content

Commit fb8c41d

Browse files
committed
restore _send_bytes()
1 parent a1e0dbd commit fb8c41d

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
@@ -466,6 +466,21 @@ def connect( # noqa: PLR0913, too many arguments in function definition
466466
raise MMQTTException(exc_msg) from last_exception
467467
raise MMQTTException(exc_msg)
468468

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

0 commit comments

Comments
 (0)