mirror of
https://github.com/python/cpython.git
synced 2024-12-04 15:25:13 +08:00
9d08423b6e
gh-117378: Fix multiprocessing forkserver preload sys.path inheritance. `sys.path` was not properly being sent from the parent process when launching the multiprocessing forkserver process to preload imports. This bug has been there since the forkserver start method was introduced in Python 3.4. It was always _supposed_ to inherit `sys.path` the same way the spawn method does. Observable behavior change: A `''` value in `sys.path` will now be replaced in the forkserver's `sys.path` with an absolute pathname `os.path.abspath(os.getcwd())` saved at the time that `multiprocessing` was imported in the parent process as it already was when using the spawn start method. **This will only be observable during forkserver preload imports**. The code invoked before calling things in another process already correctly sets `sys.path`. Which is likely why this went unnoticed for so long as a mere performance issue in some configurations. A workaround for the bug on impacted Pythons is to set PYTHONPATH in the environment before multiprocessing's forkserver process was started. Not perfect as that is then inherited by other children, etc, but likely good enough for many people's purposes. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> |
||
---|---|---|
.. | ||
dummy | ||
__init__.py | ||
connection.py | ||
context.py | ||
forkserver.py | ||
heap.py | ||
managers.py | ||
pool.py | ||
popen_fork.py | ||
popen_forkserver.py | ||
popen_spawn_posix.py | ||
popen_spawn_win32.py | ||
process.py | ||
queues.py | ||
reduction.py | ||
resource_sharer.py | ||
resource_tracker.py | ||
shared_memory.py | ||
sharedctypes.py | ||
spawn.py | ||
synchronize.py | ||
util.py |