Closed kaorihinata closed 3 months ago
Closing this as (probably) invalid. After more testing, this seems like it may be just be a poorly tested skeleton in the closet of the arm64 build of cpython, and probably not aiofiles' problem. 3.9.x was fine. Then 3.10.x, and 3.11.x were unstable. Then 3.12.x went back to being fine (api changes in 3.12.4 notwithstanding.)
I'm running into some very strange behavior when iterating over very large files using
readline
to pull out rows in chunks (this is part of some code I've inherited from somewhere else, and would be more than happy to rewrite the rest of it if we can find out what's going on.)Essentially, I've extended the parent class with the following:
self.stream
above is the result of anaiofiles.open(filepath, "rb")
, aaiofiles.threadpool.binary.AsyncBufferedReader
. After reading thousands of lines there's about a 70% chance it will end as follows:At a glance, this seems impossible. The documentation states that
timeout
should beNone
by default, and a value ofTrue
forblock
should mean thatget
then waits indefinitely for a value to become available, but here it's clearly returningEmpty
, and I cannot figure out why. The pure Python implementation ofSimpleQueue
in query.py at least seems to conform to this expectation, as does the C implementation which is being used above, but the issue always occurs inaiofiles.threadpool.binary.AsyncBufferedReader
'sreadline
coroutine, or at least, the code never reaches the line after it.Any help you can provide to figure out why this is happening would be appreciated. I apologize if I've made some incorrect assumptions above. I've spent most of the day just trying to determine who I should be filing an issue with, and I'm honestly still not 100% clear I'm in the right place as technically this is stopping in cpython code.
Opering system is macOS 15.0. Python verison is 3.11.9. aiofiles version is 23.2.1.