Skip to content

Fixed overlapped I/O when more data needs to be read #6272

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

Merged
merged 3 commits into from
Jan 31, 2019

Conversation

emmatyping
Copy link
Member

For some reason the tests didn't capture this, but ReadFile, not GetOverlappedResult returns _winapi.ERROR_MORE_DATA, which means that we would not do another read (instead we would fail an assert). This handles the case where there is more data to be read and correctly peeks then reads the remaining data.

I also increased the size of the test message to make sure we don't miss errors like this in the future, and added more information when assertions fail.

For some reason the tests didn't capture this, but ReadFile, not
GetOverlappedResult returns _winapi.ERROR_MORE_DATA, which means that we
would not do another read. This handles that and correctly peeks then
reads the remaining data.
@emmatyping emmatyping requested a review from msullivan January 30, 2019 22:14
Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

Good find!

self.name = name
self.timeout = timeout

def read(self) -> bytes:
def read(self, size: int = 100000) -> bytes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if this is worth putting in the interface, since it doesn't modify any visible behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just felt it was more fitting to put it in the function scope since it is only used for reads. To me it makes the code easier to understand (one less instance attribute to think about in the other methods).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright, sure

@msullivan msullivan merged commit 1457c5d into python:master Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants