bpo-35537: subprocess uses os.posix_spawn in some cases (GH-11452)

The subprocess module can now use the os.posix_spawn() function
in some cases for better performance. Currently, it is only used on macOS
and Linux (using glibc 2.24 or newer) if all these conditions are met:

* executable path contains a directory
* close_fds=False
* preexec_fn, pass_fds, cwd, stdin, stdout, stderr
  and start_new_session parameters are not set

Co-authored-by: Joannah Nanjekye <nanjekyejoannah@gmail.com>
This commit is contained in:
Victor Stinner 2019-01-16 00:02:35 +01:00 committed by GitHub
parent a37f52436f
commit 9daecf37a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 0 deletions

View file

@ -610,6 +610,11 @@ def collect_get_config(info_add):
info_add('%s[%s]' % (prefix, key), repr(config[key]))
def collect_subprocess(info_add):
import subprocess
copy_attributes(info_add, subprocess, 'subprocess.%s', ('_USE_POSIX_SPAWN',))
def collect_info(info):
error = False
info_add = info.add
@ -639,6 +644,7 @@ def collect_info(info):
collect_cc,
collect_gdbm,
collect_get_config,
collect_subprocess,
# Collecting from tests should be last as they have side effects.
collect_test_socket,