Skip to content

Commit 73f87c4

Browse files
committed
Explicitly set accepted socket non-blocking
The Python documentation states that otherwise, the blocking status of the newly accepted socket is implementation-defined: > if the listening socket is in non-blocking mode, whether the socket > returned by accept() is in blocking or non-blocking mode is operating > system-dependent. If you want to ensure cross-platform behaviour, > it is recommended you manually override this setting. <https://docs.python.org/3/library/socket.html#socket-timeouts> When the connected socket is non-blocking (as it is on picow), the http library works erratically, depending whether the request has already arrived by the time recvfrom_into call occurs. Closes: adafruit/circuitpython#7086
1 parent ba2da43 commit 73f87c4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

adafruit_httpserver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def poll(self):
342342
try:
343343
conn, _ = self._sock.accept()
344344
with conn:
345+
conn.setblocking(True)
345346
length, _ = conn.recvfrom_into(self._buffer)
346347

347348
request = _HTTPRequest(raw_request=self._buffer[:length])

0 commit comments

Comments
 (0)