[New-bugs-announce] [issue25994] File descriptor leaks in os.scandir()

Serhiy Storchaka report at bugs.python.org
Sat Jan 2 12:48:16 EST 2016


New submission from Serhiy Storchaka:

os.scandir() opens a file descriptor and closes it only in its destructor. This can causes file descriptor leaks in Python implementations without reference counting and if the scandir iterator becomes a part of reference loop or long living object. Since the number of open file descriptors is limited, this can leads to problems.

We need to add the close() method to the scandir iterator (as in files and generators). It would be useful also to make it a context manager.

In 3.5 we have to add a warning about this behavior.

----------
components: Extension Modules
messages: 257351
nosy: benhoyt, haypo, serhiy.storchaka
priority: high
severity: normal
status: open
title: File descriptor leaks in os.scandir()
type: resource usage
versions: Python 3.5, Python 3.6

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


More information about the New-bugs-announce mailing list