cpython/Lib/multiprocessing
Miss Islington (bot) 4e036d376e
[3.13] gh-117378: Fix multiprocessing forkserver preload sys.path inheritance. (GH-126538) (GH-126632)
gh-117378: Fix multiprocessing forkserver preload sys.path inheritance. (GH-126538)

`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.

(cherry picked from commit 9d08423b6e)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-09 15:47:58 -08:00
..
dummy
__init__.py
connection.py bpo-43952: Fix multiprocessing Listener authkey bug (GH-25845) 2024-02-27 14:57:59 +00:00
context.py
forkserver.py [3.13] gh-117378: Fix multiprocessing forkserver preload sys.path inheritance. (GH-126538) (GH-126632) 2024-11-09 15:47:58 -08:00
heap.py
managers.py [3.13] gh-126417: Register multiprocessing proxy types to an appropriate collections.abc class (#126419) (#126435) 2024-11-05 11:22:44 +00:00
pool.py gh-109649: Use os.process_cpu_count() (#110165) 2023-10-01 03:14:57 +02:00
popen_fork.py gh-83856: Honor atexit for all multiprocessing start methods (GH-114279) 2024-05-03 11:45:46 -07:00
popen_forkserver.py
popen_spawn_posix.py
popen_spawn_win32.py gh-118293: Suppress mouse cursor feedback when launching Windows processes with multiprocessing (GH-118315) 2024-04-28 21:10:44 +00:00
process.py gh-83856: Honor atexit for all multiprocessing start methods (GH-114279) 2024-05-03 11:45:46 -07:00
queues.py gh-71052: Enable test_concurrent_futures on platforms that lack multiprocessing (gh-115917) 2024-02-25 11:38:18 -08:00
reduction.py
resource_sharer.py gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (#113567) 2024-01-13 10:48:33 +01:00
resource_tracker.py gh-104090: Add exit code to multiprocessing ResourceTracker (GH-115410) 2024-02-21 13:54:57 +01:00
shared_memory.py gh-82300: Add track parameter to multiprocessing.shared_memory (#110778) 2023-12-05 00:11:44 -08:00
sharedctypes.py
spawn.py More actionable error message when spawn is incorrectly used. (#102203) 2023-08-15 18:03:45 -07:00
synchronize.py [3.13] gh-125679: multiprocessing Lock and RLock - fix invalid representation string on MacOSX. (GH-125680) (#126533) 2024-11-07 01:49:31 -08:00
util.py gh-71052: Change Android's sys.platform from "linux" to "android" 2024-03-11 19:25:39 +00:00