Skip to content

asyncio generic fails when the buffer is larger than the file contents #13719

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thelvyn
Copy link

@thelvyn thelvyn commented Aug 8, 2025

asyncio generic fails when the buffer is larger than the file contents.

Description

  1. testasyncio was updated so it fails when the error occurs using asyncio generic (works fine with liburing, not tested on windows)
  2. the fix is trivial: if the read output is <= to the read request size, then we return SDL_ASYNCIO_COMPLETE. This seems to match the expected behavior.

@icculus
Copy link
Collaborator

icculus commented Aug 9, 2025

A short read would be an error, if it isn't EOF, though. Let me look at this more closely before we merge.

@thelvyn
Copy link
Author

thelvyn commented Aug 9, 2025

The problem I encountered was that the IO remained in READY state after the read instead of EOF (even if EOF was reached).

My use case is to reuse buffers and don't query the file size before reading, that's usual with primitives like read. My logic is based on the fact that transferred_bytes < buffer_size or transferred_bytes==0 is considered as EOF so I'm done.

I agree that it is not strictly correct in case of spurious failures, I should wait for a EOF flag anyway 👍
An incomplete read is not necessarily a failure or a EOF, just that a second read should be performed to get more data or EOF (or a EAGAIN I suppose).

I can investigate this further if you want, or leave it to you.

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