-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-144503: Pass sys.argv via a route less limited by single command line argument length
#144508
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
Open
sjoerdjob
wants to merge
6
commits into
python:main
Choose a base branch
from
sjoerdjob:issue-144503-multiprocessing-forkserver-arglen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c6a3bea
gh-144503: Pass `sys.argv` as separate command line arguments.
sjoerdjob 5b8ff7b
gh-144503: Add news entry
sjoerdjob 0507aa0
gh-144503: Accept non-importable resource
sjoerdjob be2e1f0
gh-144503: Send initialization data for preload over pipe instead of …
sjoerdjob 80e7a0e
gh-144503: Harden init pipe I/O in forkserver
gpshead 13acba8
Merge remote-tracking branch 'upstream/main' into issue-144503-multip…
sjoerdjob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,8 +172,6 @@ def ensure_running(self): | |
| main_kws['sys_path'] = data['sys_path'] | ||
| if 'init_main_from_path' in data: | ||
| main_kws['main_path'] = data['init_main_from_path'] | ||
| if 'sys_argv' in data: | ||
| main_kws['sys_argv'] = data['sys_argv'] | ||
| if self._preload_on_error != 'ignore': | ||
| main_kws['on_error'] = self._preload_on_error | ||
|
|
||
|
|
@@ -197,6 +195,8 @@ def ensure_running(self): | |
| exe = spawn.get_executable() | ||
| args = [exe] + util._args_from_interpreter_flags() | ||
| args += ['-c', cmd] | ||
| if self._preload_modules: | ||
| args += data["sys_argv"] | ||
| pid = util.spawnv_passfds(exe, args, fds_to_pass) | ||
| except: | ||
| os.close(alive_w) | ||
|
|
@@ -282,7 +282,7 @@ def _handle_preload(preload, main_path=None, sys_path=None, sys_argv=None, | |
|
|
||
|
|
||
| def main(listener_fd, alive_r, preload, main_path=None, sys_path=None, | ||
| *, sys_argv=None, authkey_r=None, on_error='ignore'): | ||
| *, authkey_r=None, on_error='ignore'): | ||
| """Run forkserver.""" | ||
| if authkey_r is not None: | ||
| try: | ||
|
|
@@ -293,6 +293,11 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None, | |
| else: | ||
| authkey = b'' | ||
|
|
||
| if preload: | ||
|
Author
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. I'm kind-of inclined to think that this logic should be in |
||
| sys_argv = sys.argv[1:] | ||
| else: | ||
| sys_argv = None | ||
|
|
||
| _handle_preload(preload, main_path, sys_path, sys_argv, on_error) | ||
|
|
||
| util._close_stdin() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Library/2026-02-05-16-29-45.gh-issue-144503.f9sl_I.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fix :mod:`multiprocessing` ``forkserver`` bug which prevented starting of | ||
| the forkserver if the total length of command line arguments in ``sys.argv`` | ||
| exceeded the maximum length of a single command line argument. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.