You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under some weird circumstances, calling subprocess.run causes the child process to be locked in a loop closing all possible file descriptors. Perusing the code this is very likely some misfiring of _close_open_fds_safe. Paging @gpshead
The weird circumstances:
In a chroot, so the /proc/ filesystem is inaccessible.
Running in docker. Maybe affects the RLIMIT_NOFILE check?
Using musl? I reproduced this on an alpine container but not a debian one.
It's basically working as "intended" but this is not a code path you want to be running in. If you're seeing this as a performance issue, that suggests sysconf(_SC_OPEN_MAX) was available and returned a huge number impacting
Ideally configure your environment so the faster paths can be taken (such as having procfs). If there are alternate ways to do similar things to safely get a list of open fds or better understand the actual max fd that would work in this combination of "unique" environment bits... can you propose some logic and ways we could regression test it?
I found that I can just query this value with os.sysconf. My alpine system reports 1024, which would probably be fine, but the alpine environment in docker reports 1048576, which takes a long time to close through.
Well I couldn't figure out how to use sysctl in my environment, but it was easy enough to setrlimit(NOFILE) to a less ridiculous number. Thanks for the pointers! Closing this as I don't think there's anything reasonable that python could do differently here.
Bug report
Bug description:
Under some weird circumstances, calling subprocess.run causes the child process to be locked in a loop closing all possible file descriptors. Perusing the code this is very likely some misfiring of _close_open_fds_safe. Paging @gpshead
The weird circumstances:
Reproduction setup:
CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: