gh-155935: Stop FileFinder._find_children retrying a failing directory scan - #155939
Open
tobiaspal wants to merge 1 commit into
Open
gh-155935: Stop FileFinder._find_children retrying a failing directory scan#155939tobiaspal wants to merge 1 commit into
FileFinder._find_children retrying a failing directory scan#155939tobiaspal wants to merge 1 commit into
Conversation
…directory scan Split the `OSError` handling: an `OSError` from `next()` ends the listing, while one from `is_dir()` or `is_file()` skips just that entry.
tobiaspal
requested review from
FFY00,
brettcannon,
ericsnowcurrently,
ncoghlan and
warsaw
as code owners
August 17, 2026 06:39
picnixz
reviewed
Aug 17, 2026
| @@ -1454,6 +1454,13 @@ def _find_children(self): | |||
| while True: | |||
| try: | |||
| entry = next(scan_iterator) | |||
Member
There was a problem hiding this comment.
Why not simply entry = next(scan_iterator, None) followed by if entry is None? we're already assuming that the entry is non-None since we do entry.name just after next.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split the
OSErrorhandling: anOSErrorfromnext()ends the listing, while one fromis_dir()oris_file()skips just that entry.FileFinder._find_children()(added by gh-139900 implementing the newPathEntryFinder.discover()API proposed in gh-139899) scans a directory in awhile True:loop and ignores anyOSErrorwithout ending the loop.The
except OSError: passcovers two different failure sources:next(scan_iterator)and theos.DirEntrymethods. For aDirEntrymethod (is_dir()/is_file()racing a deletion), skipping the entry is correct. But whennext(scan_iterator)itself fails persistently (stale NFS handle, disconnected removable volume) every retry raises the sameOSErroragain,StopIterationnever arrives, and the loop never terminates.Found via @devdanzin's AI-assisted audit of
Lib/; working on it at the PyCon Korea 2026 sprint.Claude Code helped to write the tests and the fix.
FileFinder._find_childrencan loop forever on a persistently failing directory scan #155935