mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-82116: add comment explaining use of list(scandir_it)
in pathlib. (GH-94939)
Automerge-Triggered-By: GH:brettcannon
This commit is contained in:
parent
742d4614e1
commit
fd4a42d890
1 changed files with 4 additions and 0 deletions
|
@ -299,6 +299,8 @@ class _WildcardSelector(_Selector):
|
|||
|
||||
def _select_from(self, parent_path, is_dir, exists, scandir):
|
||||
try:
|
||||
# We must close the scandir() object before proceeding to
|
||||
# avoid exhausting file descriptors when globbing deep trees.
|
||||
with scandir(parent_path) as scandir_it:
|
||||
entries = list(scandir_it)
|
||||
for entry in entries:
|
||||
|
@ -330,6 +332,8 @@ class _RecursiveWildcardSelector(_Selector):
|
|||
def _iterate_directories(self, parent_path, is_dir, scandir):
|
||||
yield parent_path
|
||||
try:
|
||||
# We must close the scandir() object before proceeding to
|
||||
# avoid exhausting file descriptors when globbing deep trees.
|
||||
with scandir(parent_path) as scandir_it:
|
||||
entries = list(scandir_it)
|
||||
for entry in entries:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue