Skip to content

Commit 0480546

Browse files
committed
Changed default socket_timeout and made it possible to be a positive number only
1 parent 4a1a3a1 commit 0480546

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

adafruit_httpserver/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, socket_source: Protocol) -> None:
3131
in CircuitPython or the `socket` module in CPython.
3232
"""
3333
self._buffer = bytearray(1024)
34-
self._timeout = 0
34+
self._timeout = 1
3535
self.route_handlers = {}
3636
self._socket_source = socket_source
3737
self._sock = None
@@ -107,7 +107,7 @@ def poll(self):
107107
# Receiving data until timeout
108108
while "Receiving data":
109109
try:
110-
length = conn.recv_into(self._buffer)
110+
length = conn.recv_into(self._buffer, len(self._buffer))
111111
received_data += self._buffer[:length]
112112
except OSError as ex:
113113
if ex.errno == ETIMEDOUT:
@@ -192,9 +192,9 @@ def socket_timeout(self) -> int:
192192

193193
@socket_timeout.setter
194194
def socket_timeout(self, value: int) -> None:
195-
if isinstance(value, (int, float)) and value >= 0:
195+
if isinstance(value, (int, float)) and value > 0:
196196
self._timeout = value
197197
else:
198-
raise TypeError(
199-
"HTTPServer.socket_timeout must be a non-negative numeric value."
198+
raise ValueError(
199+
"HTTPServer.socket_timeout must be a positive numeric value."
200200
)

0 commit comments

Comments
 (0)