-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-149527: fix creation of temporary socket files post GH-148578 #149597
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
picnixz
wants to merge
5
commits into
python:main
Choose a base branch
from
picnixz:fix/forkserver/path-too-long-149527
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.
+84
−18
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
77c28e3
gh-149527: fix creation of temporary socket files post GH-148578
picnixz ab905ba
Update Lib/multiprocessing/util.py
picnixz 6a74bea
add tests
picnixz 6a78f3f
Merge branch 'main' into fix/forkserver/path-too-long-149527
picnixz 0bed495
amend
picnixz 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
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
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
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 |
|---|---|---|
| @@ -1,7 +1,42 @@ | ||
| import os | ||
| import re | ||
| import unittest | ||
| from test.support import os_helper | ||
| from multiprocessing.util import _SUN_PATH_MAX | ||
| from test._test_multiprocessing import install_tests_in_module_dict | ||
| from test.support import script_helper | ||
|
|
||
| install_tests_in_module_dict(globals(), 'forkserver', exclude_types=True) | ||
|
|
||
|
|
||
| class TestForkServerConfiguration(unittest.TestCase): | ||
| def test_respect_sun_path_max(self): | ||
| # Ensure that the calculation for temporary filepath lengths is correct. | ||
| # See https://github.com/python/cpython/issues/149527. | ||
|
|
||
| cmd = '''if 1: | ||
| from multiprocessing.connection import arbitrary_address | ||
| from multiprocessing.util import get_temp_dir | ||
| if __name__ == "__main__": | ||
| print(get_temp_dir()) | ||
| print(arbitrary_address("AF_UNIX")) | ||
| ''' | ||
| with os_helper.temp_dir() as root: | ||
| self.assertLess(len(root), _SUN_PATH_MAX) | ||
| _, out, _ = script_helper.assert_python_ok('-c', cmd, TMPDIR=root) | ||
| res = out.decode().strip().splitlines() | ||
| self.assertEqual(len(res), 2) | ||
|
|
||
| temp_pymp = res[0] | ||
| self.assertLess(len(temp_pymp), _SUN_PATH_MAX) | ||
| temp_pymp_regex = os.path.join(re.escape(root), r"pymp-\w{8}") | ||
| self.assertRegex(temp_pymp, temp_pymp_regex) | ||
|
|
||
| temp_sock = res[1] | ||
| self.assertLess(len(temp_sock), _SUN_PATH_MAX) | ||
| temp_sock_regex = os.path.join(temp_pymp_regex, r"sock-[0-9a-fA-F]{12}") | ||
| self.assertRegex(temp_sock, temp_sock_regex) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Library/2026-05-09-12-58-04.gh-issue-149527.hX36Yh.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 @@ | ||
| :mod:`multiprocessing`: fix creation of temporary socket files following | ||
| :gh:`137335` (`PR#148578 <https://github.com/python/cpython/pull/148578>`__ | ||
| and corresponding backports). Patch by Bénédikt Tran. |
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.