Message257424
> os.scandir() is called recursively in the last patch and the file descriptors are not closed until returning from the recursion.
No, os.scandir() is called non-recursively in _iterdir(), and since _iterdir() results are always accumulated in a list, a recursion starts only after exhausting the os.scandir() iterator and closing the file descriptor. We need first to resolve issue25994 to close the file descriptor explicitly.
> The glob functions should fail explicitly when scandir() raises OSERROR with posix errno set to EMFILE (The process has too many files open), or even better, silently ignore only the PermissionError exception instead of ignoring OSERROR.
Patched code passes existing tests. Do you have additional tests?
> Is the call to entry.is_symlink() in _iterdir() necessary since is_dir() follows symlinks ?
Ah, I thought is_dir() doesn't follow symlinks. Yes, now the call to entry.is_symlink() is not necessary.
> If _iterdir() would yield the DirEntry instance instead of DirEntry.name, then _rlistdir() could use x.is_dir() to know whether it is correct to iterate over _rlistdir(x.path, dironly)
Yes, but this can complicate the rest of the code. _rlistdir() is called with dironly=False only when the pattern ends with '**'. I'm not sure this is enough important case for optimization. In most cases '**' is used in the middle of the pattern, and all names yielded by _iterdir() are directory names (or broken symlinks). |
|
Date |
User |
Action |
Args |
2016-01-03 17:20:34 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, vstinner, r.david.murray, benhoyt, xdegaye |
2016-01-03 17:20:34 | serhiy.storchaka | set | messageid: <1451841634.36.0.130925695511.issue25596@psf.upfronthosting.co.za> |
2016-01-03 17:20:34 | serhiy.storchaka | link | issue25596 messages |
2016-01-03 17:20:33 | serhiy.storchaka | create | |
|