Skip to content
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

[wptserve] Remove ResponseWriter.flush() and explicit_flush #24719

Closed
Hexcles opened this issue Jul 23, 2020 · 2 comments
Closed

[wptserve] Remove ResponseWriter.flush() and explicit_flush #24719

Hexcles opened this issue Jul 23, 2020 · 2 comments

Comments

@Hexcles
Copy link
Member

Hexcles commented Jul 23, 2020

From #24617 (review):

I'd like to suggest dropping the flush method on ResponseWriter altogether to prevent any future confusion.

Digging through stdlib, I don't think there's any need to call flush ever. In both Python 2 and 3, the base HTTP server inherits from SocketServer.StreamRequestHandler with the default wbufsize = 0.

In both versions, wfile.write() ultimately calls sock.sendall which either succeeds sending all data or raises an exception: https://docs.python.org/3/library/socket.html#socket.socket.sendall

So basically, the reliable way to detect aliveness of a socket is to check wfile.write(). flush() is either not necessary (in Python 2) or non-functional (in Python 3), and should be removed for clarity.

@Hexcles
Copy link
Member Author

Hexcles commented Jul 23, 2020

We'd need to

  1. Add return statements to a few write* methods to surface caught errors from _wfile.write.
  2. Change handlers to check the return values of write instead of flush. And drop the use of flush or explicit_flush.
  3. Remove flush/explicit_flush from Response.

Hexcles pushed a commit that referenced this issue Jul 28, 2020
…24657)

This patch only drops the use of response.write.flush() in a couple of
files as they directly affect test results in Python 3.

Detailed discussions on dropping use of flush on ResponseWriter can be
found at #24617
(Also see #24719 )
@foolip
Copy link
Member

foolip commented Sep 22, 2020

@Hexcles do you plan to work on this yourself? It's labeled roadmap priority, but with nobody assigned it seems unlikely anything will happen :) Perhaps it was already fixed by some of the PRs that landed in July?

ziransun added a commit to ziransun/wpt that referenced this issue Nov 12, 2020
The reliable way to detect aliveness of a socket is to check
wfile.write(). flush() is either not necessary (in Python 2)
or non-functional (in Python 3), and should be removed for clarity.

Detailed explaination can be found at:
web-platform-tests#24719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants