GH-84559: Deprecate fork being the multiprocessing default.#100618
Conversation
This starts the process. Users who don't specify their own start method and use the default on platforms where it is 'fork' will see a DeprecationWarning upon multiprocessing.Pool() construction or upon multiprocessing.Process.start().
|
This code could be a lot cleaner if #39615 were implemented... |
Sorry, something went wrong.
gvanrossum
left a comment
There was a problem hiding this comment.
Changes to test_asyncio LGTM. I hope I won't have to review the rest, I know basically nothing about multiprocessing. :-(
Sorry, something went wrong.
kumaraditya303
left a comment
There was a problem hiding this comment.
I approve the asyncio change.
Sorry, something went wrong.
|
Please could you add this to What's New, under Pending Removal in Python 3.14? |
Sorry, something went wrong.
Ahha, I knew we had a list of upcoming things somewhere. Good idea, done! What's New text added. |
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot wasm32-emscripten node (dynamic linking) 3.x has failed when building commit 0ca67e6. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/all/#builders/1056/builds/1286 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Tests result: FAILURE == 335 tests OK. 10 slowest tests:
1 test failed: 98 tests skipped: Total duration: 21 min 59 sec Click to see traceback logsTraceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/test/test_multiprocessing_defaults.py", line 34, in test_default_fork_start_method_warning_process
process.start() # warning should point here.
^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/context.py", line 227, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/context.py", line 302, in _Popen
return super()._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/context.py", line 285, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/popen_fork.py", line 66, in _launch
self.pid = os.fork()
^^^^^^^^^
OSError: [Errno 52] Function not implemented
Traceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/test/test_multiprocessing_defaults.py", line 47, in test_default_fork_start_method_warning_pool
pool = multiprocessing.Pool(1) # warning should point here.
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/context.py", line 121, in Pool
from .pool import Pool
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/pool.py", line 30, in <module>
from .connection import wait
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/test/test_multiprocessing_defaults.py", line 75, in test_no_mp_warning_when_using_explicit_fork_context
pool = fork_mp.Pool(1)
^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/context.py", line 121, in Pool
from .pool import Pool
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/pool.py", line 30, in <module>
from .connection import wait
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/test/test_multiprocessing_defaults.py", line 61, in test_default_fork_start_method_warning_manager
manager = multiprocessing.Manager() # warning should point here.
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/context.py", line 58, in Manager
from .managers import SyncManager
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/managers.py", line 29, in <module>
from . import connection
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-dl/build/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot wasm32-emscripten node (pthreads) 3.x has failed when building commit 0ca67e6. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/all/#builders/1050/builds/1283 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Tests result: FAILURE == 339 tests OK. 10 slowest tests:
1 test failed: 94 tests skipped: Total duration: 22 min 12 sec Click to see traceback logsTraceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/test/test_multiprocessing_defaults.py", line 75, in test_no_mp_warning_when_using_explicit_fork_context
pool = fork_mp.Pool(1)
^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/context.py", line 121, in Pool
from .pool import Pool
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/pool.py", line 30, in <module>
from .connection import wait
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/test/test_multiprocessing_defaults.py", line 47, in test_default_fork_start_method_warning_pool
pool = multiprocessing.Pool(1) # warning should point here.
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/context.py", line 121, in Pool
from .pool import Pool
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/pool.py", line 30, in <module>
from .connection import wait
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/test/test_multiprocessing_defaults.py", line 61, in test_default_fork_start_method_warning_manager
manager = multiprocessing.Manager() # warning should point here.
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/context.py", line 58, in Manager
from .managers import SyncManager
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/managers.py", line 29, in <module>
from . import connection
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/test/test_multiprocessing_defaults.py", line 34, in test_default_fork_start_method_warning_process
process.start() # warning should point here.
^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/context.py", line 227, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/context.py", line 302, in _Popen
return super()._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/context.py", line 285, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node-pthreads/build/Lib/multiprocessing/popen_fork.py", line 66, in _launch
self.pid = os.fork()
^^^^^^^^^
OSError: [Errno 52] Function not implemented
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot wasm32-wasi 3.x has failed when building commit 0ca67e6. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/all/#builders/1046/builds/1328 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Tests result: FAILURE == 326 tests OK. 10 slowest tests:
1 test failed: 107 tests skipped: Total duration: 5 min 45 sec Click to see traceback logsTraceback (most recent call last):
File "/Lib/test/test_multiprocessing_defaults.py", line 47, in test_default_fork_start_method_warning_pool
pool = multiprocessing.Pool(1) # warning should point here.
^^^^^^^^^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/context.py", line 121, in Pool
from .pool import Pool
File "/Lib/multiprocessing/pool.py", line 30, in <module>
from .connection import wait
File "/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/Lib/test/test_multiprocessing_defaults.py", line 34, in test_default_fork_start_method_warning_process
process.start() # warning should point here.
^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/context.py", line 227, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/context.py", line 302, in _Popen
return super()._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/context.py", line 284, in _Popen
from .popen_fork import Popen
File "/Lib/multiprocessing/popen_fork.py", line 12, in <module>
class Popen(object):
File "/Lib/multiprocessing/popen_fork.py", line 24, in Popen
def poll(self, flag=os.WNOHANG):
^^^^^^^^^^
AttributeError: module 'os' has no attribute 'WNOHANG'
Traceback (most recent call last):
File "/Lib/test/test_multiprocessing_defaults.py", line 61, in test_default_fork_start_method_warning_manager
manager = multiprocessing.Manager() # warning should point here.
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/context.py", line 58, in Manager
from .managers import SyncManager
File "/Lib/multiprocessing/managers.py", line 29, in <module>
from . import connection
File "/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
Traceback (most recent call last):
File "/Lib/test/test_multiprocessing_defaults.py", line 75, in test_no_mp_warning_when_using_explicit_fork_context
pool = fork_mp.Pool(1)
^^^^^^^^^^^^^^^
File "/Lib/multiprocessing/context.py", line 121, in Pool
from .pool import Pool
File "/Lib/multiprocessing/pool.py", line 30, in <module>
from .connection import wait
File "/Lib/multiprocessing/connection.py", line 21, in <module>
import _multiprocessing
ModuleNotFoundError: No module named '_multiprocessing'
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 RHEL8 FIPS Only Blake2 Builtin Hash 3.x has failed when building commit 0ca67e6. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/all/#builders/469/builds/4156 Summary of the results of the build (if available): == Tests result: ENV CHANGED == 417 tests OK. 10 slowest tests:
1 test altered the execution environment: 16 tests skipped: Total duration: 13 min 33 sec Click to see traceback logsremote: Enumerating objects: 64, done.
remote: Counting objects: 1% (1/64)
remote: Counting objects: 3% (2/64)
remote: Counting objects: 4% (3/64)
remote: Counting objects: 6% (4/64)
remote: Counting objects: 7% (5/64)
remote: Counting objects: 9% (6/64)
remote: Counting objects: 10% (7/64)
remote: Counting objects: 12% (8/64)
remote: Counting objects: 14% (9/64)
remote: Counting objects: 15% (10/64)
remote: Counting objects: 17% (11/64)
remote: Counting objects: 18% (12/64)
remote: Counting objects: 20% (13/64)
remote: Counting objects: 21% (14/64)
remote: Counting objects: 23% (15/64)
remote: Counting objects: 25% (16/64)
remote: Counting objects: 26% (17/64)
remote: Counting objects: 28% (18/64)
remote: Counting objects: 29% (19/64)
remote: Counting objects: 31% (20/64)
remote: Counting objects: 32% (21/64)
remote: Counting objects: 34% (22/64)
remote: Counting objects: 35% (23/64)
remote: Counting objects: 37% (24/64)
remote: Counting objects: 39% (25/64)
remote: Counting objects: 40% (26/64)
remote: Counting objects: 42% (27/64)
remote: Counting objects: 43% (28/64)
remote: Counting objects: 45% (29/64)
remote: Counting objects: 46% (30/64)
remote: Counting objects: 48% (31/64)
remote: Counting objects: 50% (32/64)
remote: Counting objects: 51% (33/64)
remote: Counting objects: 53% (34/64)
remote: Counting objects: 54% (35/64)
remote: Counting objects: 56% (36/64)
remote: Counting objects: 57% (37/64)
remote: Counting objects: 59% (38/64)
remote: Counting objects: 60% (39/64)
remote: Counting objects: 62% (40/64)
remote: Counting objects: 64% (41/64)
remote: Counting objects: 65% (42/64)
remote: Counting objects: 67% (43/64)
remote: Counting objects: 68% (44/64)
remote: Counting objects: 70% (45/64)
remote: Counting objects: 71% (46/64)
remote: Counting objects: 73% (47/64)
remote: Counting objects: 75% (48/64)
remote: Counting objects: 76% (49/64)
remote: Counting objects: 78% (50/64)
remote: Counting objects: 79% (51/64)
remote: Counting objects: 81% (52/64)
remote: Counting objects: 82% (53/64)
remote: Counting objects: 84% (54/64)
remote: Counting objects: 85% (55/64)
remote: Counting objects: 87% (56/64)
remote: Counting objects: 89% (57/64)
remote: Counting objects: 90% (58/64)
remote: Counting objects: 92% (59/64)
remote: Counting objects: 93% (60/64)
remote: Counting objects: 95% (61/64)
remote: Counting objects: 96% (62/64)
remote: Counting objects: 98% (63/64)
remote: Counting objects: 100% (64/64)
remote: Counting objects: 100% (64/64), done.
remote: Compressing objects: 3% (1/32)
remote: Compressing objects: 6% (2/32)
remote: Compressing objects: 9% (3/32)
remote: Compressing objects: 12% (4/32)
remote: Compressing objects: 15% (5/32)
remote: Compressing objects: 18% (6/32)
remote: Compressing objects: 21% (7/32)
remote: Compressing objects: 25% (8/32)
remote: Compressing objects: 28% (9/32)
remote: Compressing objects: 31% (10/32)
remote: Compressing objects: 34% (11/32)
remote: Compressing objects: 37% (12/32)
remote: Compressing objects: 40% (13/32)
remote: Compressing objects: 43% (14/32)
remote: Compressing objects: 46% (15/32)
remote: Compressing objects: 50% (16/32)
remote: Compressing objects: 53% (17/32)
remote: Compressing objects: 56% (18/32)
remote: Compressing objects: 59% (19/32)
remote: Compressing objects: 62% (20/32)
remote: Compressing objects: 65% (21/32)
remote: Compressing objects: 68% (22/32)
remote: Compressing objects: 71% (23/32)
remote: Compressing objects: 75% (24/32)
remote: Compressing objects: 78% (25/32)
remote: Compressing objects: 81% (26/32)
remote: Compressing objects: 84% (27/32)
remote: Compressing objects: 87% (28/32)
remote: Compressing objects: 90% (29/32)
remote: Compressing objects: 93% (30/32)
remote: Compressing objects: 96% (31/32)
remote: Compressing objects: 100% (32/32)
remote: Compressing objects: 100% (32/32), done.
remote: Total 36 (delta 30), reused 7 (delta 4), pack-reused 0
From https://github.com/python/cpython
* branch main -> FETCH_HEAD
Note: switching to '0ca67e6313c11263ecaef7ce182308eeb5aa6814'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 0ca67e6313 GH-84559: Deprecate fork being the multiprocessing default. (#100618)
Switched to and reset branch 'main'
make: *** [Makefile:1912: buildbottest] Error 3 |
Sorry, something went wrong.
This reverts the core of python#100618 while leaving relevant documentation improvements and minor refactorings in place.
The default of `fork` is known to be problematic. Python itself is changing the default to `spawn`. The new default is expected to be in place for Python 3.14. Python references for the change to the default: * python/cpython#84559 * python/cpython#100618 We also have several places where this option had to be set to `spawn` to make tests work. The AMD code even checks and overrides the value if it's not set to `spawn`. Simplify things for everyone and just default to `spawn`, but leave the option in place just in case, at least for now. Signed-off-by: Russell Bryant <rbryant@redhat.com>
This starts the process. Users who don't specify their own start method and use the default on platforms where it is 'fork' will see a DeprecationWarning upon multiprocessing.Pool() construction or upon multiprocessing.Process.start().
'fork'is broken: change to `'forkserver' || 'spawn'#84559