Skip to content

Commit d60ab23

Browse files
committed
remove duplicate _sock_exact_recv() definition
1 parent 0e5bb0c commit d60ab23

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -313,35 +313,6 @@ def __enter__(self):
313313
def __exit__(self, exception_type, exception_value, traceback):
314314
self.deinit()
315315

316-
def _sock_exact_recv(self, bufsize):
317-
"""Reads _exact_ number of bytes from the connected socket. Will only return
318-
string with the exact number of bytes requested.
319-
320-
The semantics of native socket receive is that it returns no more than the
321-
specified number of bytes (i.e. max size). However, it makes no guarantees in
322-
terms of the minimum size of the buffer, which could be 1 byte. This is a
323-
wrapper for socket recv() to ensure that no less than the expected number of
324-
bytes is returned or trigger a timeout exception.
325-
326-
:param int bufsize: number of bytes to receive
327-
"""
328-
stamp = time.monotonic()
329-
rc = self._sock.recv(bufsize)
330-
to_read = bufsize - len(rc)
331-
assert to_read >= 0
332-
read_timeout = self.keep_alive
333-
while to_read > 0:
334-
recv = self._sock.recv(to_read)
335-
to_read -= len(recv)
336-
rc += recv
337-
if time.monotonic() - stamp > read_timeout:
338-
raise MMQTTException(
339-
"Unable to receive {} bytes within {} seconds.".format(
340-
to_read, read_timeout
341-
)
342-
)
343-
return rc
344-
345316
def deinit(self):
346317
"""De-initializes the MQTT client and disconnects from the mqtt broker."""
347318
self.disconnect()

0 commit comments

Comments
 (0)