Closed jepler closed 2 years ago
Explicitly set accepted socket blocking?
I changed the title and the commit message, thanks!
How is this intended to work with a httpserver using poll() in a loop?
Other tasks in the program function properly, calling poll every loop. The first time a connection is made to the httpserver, then the connection transitions to blocking, then everything else in the program stops working indefinitely.
When explicitly transitioning to blocking mode, would it make sense to optionally set a timeout to allow things to transition back to non-blocking?
How is this intended to work with a httpserver using poll() in a loop?
it does now work with poll() in the loop. and does not block other things while waiting to requests. this was not possible before this fix.
testet with CP 8 beta 3 + this very change on pico-w.
Yes, same upgrade to Circuitpython and httpserver on a picoW. What browser are you using?
Firefox: Everything works fine. Chrome: Socket/connection is left in a blocking state. But the block actually comes after the web page is loaded, it appears that chrome is reopening a connection in anticipation of the next request.
It is actually this call that is blocking, when there are no bytes to receive. https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/blob/f9345f2d694838604a54bda3468d66fd5e4abb68/adafruit_httpserver.py#L346
I'll move this to a new issue.
Yes, same upgrade to Circuitpython and httpserver on a picoW. What browser are you using?
Firefox: Everything works fine.
i used the lastest release that containes the fix https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/releases/tag/0.5.3 and it workes in FF and in chrome and it can load the page as often i want including a asset that is loaded from the document. all while code in loop is doing even other stuff
The Python documentation states that otherwise, the blocking status of the newly accepted socket is implementation-defined:
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