-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
glob
empty return when ulimit -n
is reached
#103501
Comments
glob
empty return when ulimit
is reachedglob
empty return when ulimit -n
is reached
What is the behavior of the pathname expansion in the Unix shell in such case? Errors like broken symlinks, permission deny, too long path are ignored. Maybe all errors are ignored. And Maybe in future we will add an option to make |
This might be a good use case for ExceptionGroup :) The current behaviour is that OSError are ignored. See recent discussions in e.g. #104292 and (for But |
It is not a good case for ExceptionGroup. There might be many thousands files and directories in the tree. There are three strategies to handle errors:
The "fail" and "ignore" strategies are supported in other complex operations (like |
FWIW, pathlib calls |
Right. ExceptionGroup only works for “ignore” (for logging the errors). The 3 strategies can be mixed. Thinking about it, in most of my uses of glob, I'm OK with ignoring |
Bug report
When having a lot of opened files, glob can return an empty list rather than either raising an error or returning a non-empty list.
With a
ulimit
set at 256 (ulimit -n 256
), and with a file namedfoo
:My intuition is that
glob
should inform the user that it couldn't do its job properly (likeopen
raisesOSError
if we try to open too many files), because right now there's an uncertainty on whether a given folder is empty orulimit -n
has been reached.An OSError is caught in
glob.py
, but not propagated: https://github.com/python/cpython/blob/3.11/Lib/glob.py#L172Your environment
python:latest
), both x86_64Linked PRs
The text was updated successfully, but these errors were encountered: