ID EN
OS

closerange

Python 3.11

Close all file descriptors from fd_low (inclusive) to fd_high (exclusive), ignoring errors. Equivalent to (but much faster than):

Syntax

PYTHON
os.closerange(fd_low, fd_high, /)

Examples

Example 1
PYTHON
for fd in range(fd_low, fd_high):
    try:
        os.close(fd)
    except OSError:
        pass