[issue25995] os.walk() consumes a lot of file descriptors

Serhiy Storchaka report at bugs.python.org
Mon Jan 11 16:35:22 EST 2016


Serhiy Storchaka added the comment:

Both patches are basically equivalent. The first one collects all scandir() results in a list, the second one collects only directory names in a list. The purpose of using os.scandir() in os.walk() was a speed up (issue23605), and both patches preserve it.

Yes, the number of FDs used is equivalent to the depth of the tree which can be very deep (I just created a tree depth of 1000 levels). And what is worse, all these FDs can be effectively leaked if the walking was not finished. This is unwanted behavior change.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25995>
_______________________________________


More information about the Python-bugs-list mailing list