[Python-checkins] cpython (3.5): Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.

serhiy.storchaka python-checkins at python.org
Thu Feb 11 06:32:16 EST 2016


https://hg.python.org/cpython/rev/e951d76f1945
changeset:   100227:e951d76f1945
branch:      3.5
parent:      100224:e9a4b30e3e43
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Thu Feb 11 13:29:28 2016 +0200
summary:
  Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.

files:
  Lib/os.py |  13 ++-----------
  Misc/NEWS |   2 ++
  2 files changed, 4 insertions(+), 11 deletions(-)


diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -369,22 +369,13 @@
             # Note that scandir is global in this module due
             # to earlier import-*.
             scandir_it = scandir(top)
+        entries = list(scandir(top))
     except OSError as error:
         if onerror is not None:
             onerror(error)
         return
 
-    while True:
-        try:
-            try:
-                entry = next(scandir_it)
-            except StopIteration:
-                break
-        except OSError as error:
-            if onerror is not None:
-                onerror(error)
-            return
-
+    for entry in entries:
         try:
             is_dir = entry.is_dir()
         except OSError:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -73,6 +73,8 @@
 Library
 -------
 
+- Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.
+
 - Issue #26117: The os.scandir() iterator now closes file descriptor not only
   when the iteration is finished, but when it was failed with error.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list