Propagate all -X command line options to multiprocessing spawned child Python processes.
# -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
# -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')
--- /dev/null
+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``,
+``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``.