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

fix: Address flaky integration test #130

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

aiven-anton
Copy link
Collaborator

Trying to figure this one out, I read up again on the documentation of StreamWriter.read() and took extra note of this passage.

[...] return at most n available bytes as soon as at least 1 byte is
available in the internal buffer.

After switching to use .readexactly() instead, the error systematically stops occurring.

Trying to figure this one out, I read up again on the [documentation] of
`StreamWriter.read()` and took extra note of this passage.

[documentation]: https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamReader.read

> [...] return at most n available bytes as soon as at least 1 byte is
> available in the internal buffer.

After switching to use `.readexactly()` instead, the error
systematically stops ocurring.
@aiven-anton aiven-anton marked this pull request as ready for review February 6, 2024 20:11
@aiven-anton aiven-anton requested review from a team as code owners February 6, 2024 20:11
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c57a4bd) 96.67% compared to head (c36685e) 96.67%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #130   +/-   ##
=======================================
  Coverage   96.67%   96.67%           
=======================================
  Files          14       14           
  Lines        1023     1023           
  Branches      139      139           
=======================================
  Hits          989      989           
  Misses         26       26           
  Partials        8        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@eliax1996 eliax1996 left a comment

Choose a reason for hiding this comment

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

Make sense! Great finding, I'm wondering if the IO read method could have the same behaviour. I tried to open the class in typing but I cannot see any guarantee nor doc about the read method.
Do you know where we can look for it?

@eliax1996 eliax1996 added this pull request to the merge queue Feb 14, 2024
Merged via the queue into main with commit 22c36c6 Feb 14, 2024
12 checks passed
@eliax1996 eliax1996 deleted the aiven-anton/fix-flaky-produce-consume branch February 14, 2024 09:50
@aiven-anton
Copy link
Collaborator Author

@eliax1996 IO is just a protocol so it doesn't really have opinions of how many bytes the method should return.

Note that there was also a previous related fix for all the lower-level read functions: #117. Prior to that, some of them would silently accept fewer bytes than expected, but the fix makes them fail loudly.

@aiven-anton
Copy link
Collaborator Author

IO is just a protocol so it doesn't really have opinions of how many bytes the method should return.

And this would probably require dependent types to express with the type system 😁

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.

3 participants