-
Notifications
You must be signed in to change notification settings - Fork 32
Explicitly set accepted socket to blocking #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Explicitly set accepted socket blocking? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on PiCow and regression-tested on ESP32-S2. Vast improvement on PiCow.
But I think the PR title is backwards.
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
73f87c4
to
cee7f22
Compare
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? |
Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 0.5.3 from 0.5.2: > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#19 from jepler/explicit-blocking
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. It is actually this call that is blocking, when there are no bytes to receive.
I'll move this to a new issue. |
i used the lastest release that containes the fix https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/releases/tag/0.5.3 |
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