Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.53k stars 1.25k forks source link

Performance penalty for iteratively executing `os.close` #1540

Closed tyong920 closed 2 years ago

tyong920 commented 2 years ago

As per Python official document on os.closerange

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

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

It's better replace with it. https://github.com/Supervisor/supervisor/blob/906d2adec9bd27d54cdff48bdd12f6cb42bf9546/supervisor/options.py#L1329-L1333

mnaberez commented 2 years ago

Continued in #1541