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

bpo-30861: Return StreamReeader remaining buffer before raise excepiton #2593

Conversation

pfreixes
Copy link

@pfreixes pfreixes commented Jul 5, 2017

The current implementation of StreamReader does not take care of the status of the buffer, once an exception has been set via set_exception any call to the read methods won't be able to get the missing data still pending to be processed.

From the point of view of the developer, if there is no scheduled task for waiting for data into the Streamreader between a network data gets into the buffer socket and a closing connection by the other peer arrives, the developer won't be able to gather the previous data.

This PR take care first of the remaining buffer and try to return first to the user, and only when the buffer has run out raises the proper exception

@gvanrossum
Copy link
Member

PS. Let's keep the discussion in the bpo issue (http://bugs.python.org/issue30861).

@@ -571,6 +571,11 @@ def readuntil(self, separator=b'\n'):
self._buffer.clear()
raise IncompleteReadError(chunk, None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the fact that this code path can swallow the previously set self._exception.

@1st1
Copy link
Member

1st1 commented May 29, 2018

Could you please rebase your PR against the latest master branch?

@pfreixes
Copy link
Author

pfreixes commented Jun 7, 2018

Superseded by #7473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants