]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-141860: Add on_error= keyword arg to `multiprocessing.set_forkserver_preload`...
authorGregory P. Smith <68491+gpshead@users.noreply.github.com>
Sun, 18 Jan 2026 22:04:18 +0000 (14:04 -0800)
committerGitHub <noreply@github.com>
Sun, 18 Jan 2026 22:04:18 +0000 (14:04 -0800)
commitc879b2a7a52549dd310aa1cca1a00ff8f36a25ba
tree78c5fb8f91f8c6bbe8e37354fcd8c5c2bc407a34
parent54bedcf714160c3ecff3103a53f6291a7e1efd27
gh-141860: Add on_error= keyword arg to `multiprocessing.set_forkserver_preload` (GH-141859)

Add a keyword-only `on_error` parameter to `multiprocessing.set_forkserver_preload()`. This allows the user to have exceptions during optional `forkserver` start method module preloading cause the forkserver subprocess to warn (generally to stderr) or exit with an error (preventing use of the forkserver) instead of being silently ignored.

This _also_ fixes an oversight, errors when preloading a `__main__` module are now treated the similarly. Those would always raise unlike other modules in preload, but that had gone unnoticed as up until bug fix PR GH-135295 in 3.14.1 and 3.13.8, the `__main__` module was never actually preloaded.

Based on original work by Nick Neumann @aggieNick02 in GH-99515.
Doc/library/multiprocessing.rst
Lib/multiprocessing/context.py
Lib/multiprocessing/forkserver.py
Lib/test/test_multiprocessing_forkserver/__init__.py
Lib/test/test_multiprocessing_forkserver/test_preload.py [new file with mode: 0644]
Misc/ACKS
Misc/NEWS.d/next/Library/2025-11-22-20-30-00.gh-issue-141860.frksvr.rst [new file with mode: 0644]