diff --git a/Lib/multiprocessing/forkserver.py b/Lib/multiprocessing/forkserver.py index c91891ff162c2d..14b465c3a08bf8 100644 --- a/Lib/multiprocessing/forkserver.py +++ b/Lib/multiprocessing/forkserver.py @@ -146,9 +146,9 @@ def ensure_running(self): 'main(%d, %d, %r, **%r)') if self._preload_modules: - desired_keys = {'main_path', 'sys_path'} + desired_keys = {'main_path': 'init_main_from_path', 'sys_path': 'sys_path'} data = spawn.get_preparation_data('ignore') - main_kws = {x: y for x, y in data.items() if x in desired_keys} + main_kws = {x: data[y] for x, y in desired_keys.items() if y in data} else: main_kws = {} diff --git a/Misc/NEWS.d/next/Library/2025-08-23-00-59-59.gh-issue-137996.6pkMXl.rst b/Misc/NEWS.d/next/Library/2025-08-23-00-59-59.gh-issue-137996.6pkMXl.rst new file mode 100644 index 00000000000000..e70a5b1135bcae --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-08-23-00-59-59.gh-issue-137996.6pkMXl.rst @@ -0,0 +1,3 @@ +:mod:`multiprocessing`: Fix preloading of ``__main__`` for +:ref:`forkserver ` +start method.