-
Notifications
You must be signed in to change notification settings - Fork 146
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
anyio.Path.iterdir
blocks in Python 3.13
#873
Labels
bug
Something isn't working
Comments
I would prefer not to introduce any breaking changes, but instead reimplement the async iterator in a way that defers any I/O until the first iteration, like how it used to work. |
cbornet
added a commit
to cbornet/anyio
that referenced
this issue
Feb 20, 2025
3 tasks
cbornet
added a commit
to cbornet/anyio
that referenced
this issue
Feb 20, 2025
cbornet
added a commit
to cbornet/anyio
that referenced
this issue
Feb 20, 2025
cbornet
added a commit
to cbornet/anyio
that referenced
this issue
Feb 20, 2025
agronholm
added a commit
that referenced
this issue
Feb 21, 2025
Fixes #873. --------- Co-authored-by: Alex Grönholm <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
AnyIO version
HEAD
Python version
3.13
What happened?
Python 3.13 introduced a breaking change on how
pathlib.Path.iterdir
behaves.iterdir
now materializes the list of files eagerly. See python/cpython#129871 .The reason for this change was to raise OS errors directly and not at the first iteration : python/cpython#78722
anyio.Path.iterdir
is callingpathlib.Path.iterdir
directly (not in a thread)anyio/src/anyio/_core/_fileio.py
Line 548 in 8bad9c0
and probably users would expect it not to block.
Some possibilities to fix would be:
anyio.Path.iterdir
to not usepathlib.Path.iterdir
and useos.scandir
directly without materializing the iterator. In this case, there will be a small difference withpathlib.Path.iterdir
that OS errors will only happen when we start iterating.anyio.Path.iterdir
async which is a breaking change.LMK what you think. I can do a PR.
How can we reproduce the bug?
N/A
The text was updated successfully, but these errors were encountered: