Skip to content

Commit

Permalink
Merge pull request #44 from cpforbes/socket_timeout
Browse files Browse the repository at this point in the history
2 fixes for adafruit_esp32spi_socket.socket
  • Loading branch information
ladyada authored May 11, 2019
2 parents 1fe7e85 + 83f46d2 commit fce3410
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adafruit_esp32spi/adafruit_esp32spi_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def connect(self, address, conntype=None):
a hostname string). 'conntype' is an extra that may indicate SSL or not,
depending on the underlying interface"""
host, port = address
if conntype is None:
conntype = _the_interface.TCP_MODE
if not _the_interface.socket_connect(self._socknum, host, port, conn_mode=conntype):
raise RuntimeError("Failed to connect to host", host)
self._buffer = b''
Expand Down Expand Up @@ -123,7 +125,7 @@ def read(self, size=0):
received.append(recv)
to_read -= len(recv)
gc.collect()
if time.monotonic() - stamp > self._timeout:
if self._timeout > 0 and time.monotonic() - stamp > self._timeout:
break
#print(received)
self._buffer += b''.join(received)
Expand Down

0 comments on commit fce3410

Please sign in to comment.