GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-155935: Stop `FileFinder._find_children` retrying a failing directory scan by tobiaspal · Pull Request #155939 · python/cpython

Conversation

@tobiaspal

@tobiaspal tobiaspal commented Aug 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Split the OSError handling: an OSError from next() ends the listing, while one from is_dir() or is_file() skips just that entry.

FileFinder._find_children() (added by gh-139900 implementing the new PathEntryFinder.discover() API proposed in gh-139899) scans a directory in a while True: loop and ignores any OSError without ending the loop.

The except OSError: pass covers two different failure sources: next(scan_iterator) and the os.DirEntry methods. For a DirEntry method (is_dir()/is_file() racing a deletion), skipping the entry is correct. But when next(scan_iterator) itself fails persistently (stale NFS handle, disconnected removable volume) every retry raises the same OSError again, StopIteration never 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.

  • Issue: FileFinder._find_children can loop forever on a persistently failing directory scan #155935

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tobiaspal
pythongh-155935: Stop FileFinder._find_children retrying a failing …
929338d
…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
tobiaspal requested review from FFY00, brettcannon, ericsnowcurrently, ncoghlan and warsaw as code owners August 17, 2026 06:39
@bedevere-app bedevere-app Bot mentioned this pull request Aug 17, 2026
FileFinder._find_children can loop forever on a persistently failing directory scan #155935
Open
@bedevere-app bedevere-app Bot added the awaiting review label Aug 17, 2026
@corona10 corona10 added the sprint label Aug 17, 2026
@github-project-automation github-project-automation Bot added this to Sprint Aug 17, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint Aug 17, 2026
picnixz
picnixz reviewed Aug 17, 2026
View reviewed changes
Comment thread Lib/importlib/_bootstrap_external.py
@@ -1454,6 +1454,13 @@ def _find_children(self):
while True:
try:
entry = next(scan_iterator)

@picnixz picnixz Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@picnixz picnixz picnixz left review comments
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review sprint

Projects

Sprint
Status: Todo

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@tobiaspal @picnixz @corona10
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.