[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2021-12-17 Thread Cristian Rodriguez
Cristian Rodriguez added the comment: My 2 CLP. On linux/glibc you do not have to do this, there is a posix_spawn_file_actions_addclosefrom_np action which is implemented using close_range(2) which will give you the fastest way to this job without hassle. for the not posix_spawn case,

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2021-10-27 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Gregory P. Smith wrote: > A higher level "best practices for launching child processes module" with > APIs reflecting explicit intents (performance vs security vs simplicity) > rather than requiring users to understand subprocess platform specific >

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2021-10-27 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: > As a concrete example, we have a (non-Python) build system and task runner > that orchestrates many tasks to run in parallel. Some of those tasks end up > invoking Python scripts that use subprocess.run() to run other programs. Our > task runner

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2021-10-26 Thread Richard Xia
Richard Xia added the comment: I'd like to provide another, non-performance-related use case for changing the default value of Popen's close_fds parameters back to False. In some scenarios, a (non-Python) parent process may want its descendant processes to inherit a particular file

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2020-12-28 Thread Eryk Sun
Eryk Sun added the comment: > Python 3.7 added the support for the PROC_THREAD_ATTRIBUTE_HANDLE_LIST > in subprocess.STARTUPINFO: lpAttributeList['handle_list'] parameter. The motivating reason to add support for the WinAPI handle list was to allow changing the default to close_fds=True

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2020-12-27 Thread Gregory P. Smith
Gregory P. Smith added the comment: Note that vfork() support has been merged for 3.10 via bpo-35823, so posix_spawn() is less of a performance carrot than it used to be on Linux. vfork() exists macOS, that code could likely be enabled there after some investigation+testing. Regardless,

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2020-12-26 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: > Using close_fds=False, subprocess can use posix_spawn() which is safer and > faster than fork+exec. For example, on Linux, the glibc implements it as a > function using vfork which is faster than fork if the parent allocated a lot > of memory. On macOS,

[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2020-12-25 Thread STINNER Victor
New submission from STINNER Victor : To make subprocess faster, I propose to no longer close all file descriptors by default in subprocess: change Popen close_fds parameter default to False (close_fds=False). Using close_fds=False, subprocess can use posix_spawn() which is safer and faster