You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The multiprocessing module's forkserver start method multiprocessing.forkserver.main has two arguments that are values passed from the parent process to the forkserver when first launching it. main_path= and sys_path=. Via code inspection while fixing and testing #126538:
There is no possible way for main_path= to be set on the multiprocessing's forkserver.main() call since 2013's 9a76735 for #64145 as shipped in 3.4 (which also introduced the forkserver feature).
the forkserver.main(...) call is constructed in Lib/multiprocessing/forkserver.py getting its two possible allowed named args from spawn.get_preparation_data() in Lib/multiprocessing/spawn.py which was changed to set "init_main_from_name" in the kwargs dict it returns instead of "main_path" in the above change. Effectively making the main_path= handling code dead in forkserver.main.
We should either remove the dead code, or determine if it was intended to support something that has been silently broken when using the forkserver start method for the past 11 years, and if so, add an explicit test for that and adapt it to use "init_main_from_name" as the spawn code does.
importing __main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946571
importing __mp_main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946574
running in 946574
importing __mp_main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946575
running in 946575
importing __mp_main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946576
running in 946576
importing __mp_main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946577
running in 946577
If we fix it (and presumably before 3.4, although I haven't tested):
importing __main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946458
importing __mp_main__ (/home/duaneg/src/cpython/data/126631/repro.py) pid=946460
running in 946461
running in 946462
running in 946463
running in 946464
Having said that, no-one noticing for eleven years suggests it isn't actually required. Perhaps it would be better to simplify things and remove the code? I'll post a quick and dirty fix, for reference.
duaneg
added a commit
to duaneg/cpython
that referenced
this issue
Jun 9, 2025
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
The
multiprocessing
module's forkserver start methodmultiprocessing.forkserver.main
has two arguments that are values passed from the parent process to the forkserver when first launching it.main_path=
andsys_path=
. Via code inspection while fixing and testing #126538:There is no possible way for
main_path=
to be set on the multiprocessing's forkserver.main() call since 2013's 9a76735 for #64145 as shipped in 3.4 (which also introduced the forkserver feature).the
forkserver.main(...)
call is constructed in Lib/multiprocessing/forkserver.py getting its two possible allowed named args fromspawn.get_preparation_data()
inLib/multiprocessing/spawn.py
which was changed to set"init_main_from_name"
in the kwargs dict it returns instead of"main_path"
in the above change. Effectively making themain_path=
handling code dead inforkserver.main
.We should either remove the dead code, or determine if it was intended to support something that has been silently broken when using the forkserver start method for the past 11 years, and if so, add an explicit test for that and adapt it to use
"init_main_from_name"
as the spawn code does.CPython versions tested on:
3.12, 3.13, 3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: