FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-146004: propagate all -X options to multiprocessing child processes (GH-146005) by danielKim614 · Pull Request #155938 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 10 additions & 9 deletions Lib/subprocess.py
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
Expand Up @@ -351,15 +351,16 @@ def _args_from_interpreter_flags():
# -X options
if dev_mode:
args.extend(('-X', 'dev'))
for opt in ('faulthandler', 'tracemalloc', 'importtime',
'frozen_modules', 'showrefcount', 'utf8', 'gil'):
if opt in xoptions:
value = xoptions[opt]
if value is True:
arg = opt
else:
arg = '%s=%s' % (opt, value)
args.extend(('-X', arg))
for opt in sorted(xoptions):
if opt == 'dev':
# handled above via sys.flags.dev_mode
continue
value = xoptions[opt]
if value is True:
arg = opt
else:
arg = '%s=%s' % (opt, value)
args.extend(('-X', arg))

return args

Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_support.py
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
Expand Up @@ -560,11 +560,19 @@ def test_args_from_interpreter_flags(self):
# -X options
['-X', 'dev'],
['-Wignore', '-X', 'dev'],
['-X', 'cpu_count=4'],
['-X', 'disable-remote-debug'],
['-X', 'faulthandler'],
['-X', 'importtime'],
['-X', 'importtime=2'],
['-X', 'int_max_str_digits=1000'],
['-X', 'lazy_imports=all'],
['-X', 'no_debug_ranges'],
['-X', 'pycache_prefix=/tmp/pycache'],
['-X', 'showrefcount'],
['-X', 'tracemalloc'],
['-X', 'tracemalloc=3'],
['-X', 'warn_default_encoding'],
):
with self.subTest(opts=opts):
self.check_options(opts, 'args_from_interpreter_flags')
Expand Down
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,9 @@
All :option:`-X` options from the Python command line are now propagated to
child processes spawned by :mod:`multiprocessing`, not just a hard-coded
subset. This makes the behavior consistent between default "spawn" and
"forkserver" start methods and the old "fork" start method. The options
that were previously not propagated are: ``context_aware_warnings``,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Strictly speaking, not all of these apply to 3.13, for examply lazy_imports is 3.15. We haven't been that picky in the 3.14 backport, either, and the tests pass, because unsupported -X options are just silently ignored.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for catching this and for opening #155965!
Using os_helper.temp_dir() should make the test portable on Windows.
Good point about the version-specific options as well.

``cpu_count``, ``disable-remote-debug``, ``int_max_str_digits``,
``lazy_imports``, ``no_debug_ranges``, ``pathconfig_warnings``, ``perf``,
``perf_jit``, ``presite``, ``pycache_prefix``, ``thread_inherit_context``,
and ``warn_default_encoding``.
Loading

Back | FazBrowse Home | New Git URL