Skip to content
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

bpo-35537: Change subprocess to use posix_spawnp instead of posix_spawn #11917

Closed
wants to merge 6 commits into from

Conversation

nanjekyejoannah
Copy link
Contributor

@nanjekyejoannah nanjekyejoannah commented Feb 18, 2019

I have added a change to make subprocess.py to use posix_spawnp instead of posix_spawn.

cc @vstinner

https://bugs.python.org/issue35537

@nanjekyejoannah nanjekyejoannah changed the title change subprocess to use posix_spawnp instead of posix_spawn bpo-35537: Change subprocess to use posix_spawnp instead of posix_spawn Feb 18, 2019
@@ -1525,7 +1523,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
if executable is None:
executable = args[0]

if (_USE_POSIX_SPAWN
if (_USE_POSIX_SPAWNP
and os.path.dirname(executable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole purpose of the change is to remove "and os.path.dirname(executable)" but you kept the test... Please remove it!

@@ -0,0 +1 @@
subprocess.py now uses posix_spawnp instead of posix_spawn.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can enhance the entry using better formatting, and please avoid ".py" when you mention a module. User use "import subprocess", they don't access directly to subprocess.py. NEWS entries are for end users.

Suggested change
subprocess.py now uses posix_spawnp instead of posix_spawn.
The :mod:`subprocess` now uses :func:`os.posix_spawnp` instead of :func:`os.posix_spawn`.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, one last thing: your PR makes the following doc outdated:
https://docs.python.org/dev/whatsnew/3.8.html#optimizations

Please update: "The subprocess module can now use the os.posix_spawn() function...": it's now posix_spawnp. Moreover, "the executable path contains a directory." condition can now be removed. Well, update the doc :-)

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@izbyshev
Copy link
Contributor

The previous attempt was reverted because of semantic differences between posix_spawnp and the existing behavior of subprocess. What has changed since that attempt? Is there any discussion I could follow to understand that?

@@ -317,14 +317,13 @@ xml
Optimizations
=============

* The :mod:`subprocess` module can now use the :func:`os.posix_spawn` function
* The :mod:`subprocess` module can now use the :func:`os.posix_spawnp` 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:

* *close_fds* is false;
* *preexec_fn*, *pass_fds*, *cwd* and *start_new_session* parameters
are not set;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "are not set;" should become "are not set."

@@ -1535,7 +1532,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
and (c2pwrite == -1 or c2pwrite > 2)
and (errwrite == -1 or errwrite > 2)
and not start_new_session):
self._posix_spawn(args, executable, env, restore_signals,
self._posix_spawnp(args, executable, env, restore_signals,
p2cread, p2cwrite,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the indentation: p2cread must be indentation with args.

@vstinner
Copy link
Member

The previous attempt was reverted because of semantic differences between posix_spawnp and the existing behavior of subprocess. What has changed since that attempt? Is there any discussion I could follow to understand that?

Oh.... It was last month but I already completely forgot my own previous attempt :-(

@vstinner
Copy link
Member

@nanjekyejoannah: Sorry, but I forgot that I made exactly the same change last month but we had to revert it... See @izbyshev's comment:
"The previous attempt was reverted because of semantic differences between posix_spawnp and the existing behavior of subprocess. What has changed since that attempt? Is there any discussion I could follow to understand that?"

I close your PR.

@vstinner vstinner closed this Feb 19, 2019
@nanjekyejoannah
Copy link
Contributor Author

cool noted!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants