-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-35537: use os.posix_spawn in subprocess #11242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1390,6 +1390,10 @@ def _get_handles(self, stdin, stdout, stderr): | |
errread, errwrite) | ||
|
||
|
||
def _posix_spawn(self, args, executable): | ||
"""Execute program using os.posix_spawn().""" | ||
self.pid = os.posix_spawn(executable, args, os.environ) | ||
|
||
def _execute_child(self, args, executable, preexec_fn, close_fds, | ||
pass_fds, cwd, env, | ||
startupinfo, creationflags, shell, | ||
|
@@ -1414,6 +1418,21 @@ def _execute_child(self, args, executable, preexec_fn, close_fds, | |
|
||
if executable is None: | ||
executable = args[0] | ||
|
||
if (os.path.dirname(executable) | ||
and preexec_fn is None | ||
and not close_fds | ||
and not pass_fds | ||
and cwd is None | ||
and env is None | ||
and p2cread == p2cwrite == -1 | ||
and c2pread == c2pwrite == -1 | ||
and errread == errwrite == -1 | ||
and not restore_signals | ||
and not start_new_session): | ||
self._posix_spawn(args, executable) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @izbyshev: Oh right! I fixed the test: test (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) instead of (self.stdin, self.stdout, self.stderr). Is it better now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, LGTM now. There is another potential problem with |
||
return | ||
|
||
orig_executable = executable | ||
|
||
# For transferring possible exec failure from child to parent. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
subprocess.Popen can now use posix_spawn() in some cases. |
Uh oh!
There was an error while loading. Please reload this page.