diff options
author | Gregory P. Smith <greg@krypto.org> | 2023-02-02 23:50:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-02 23:50:35 (GMT) |
commit | 0ca67e6313c11263ecaef7ce182308eeb5aa6814 (patch) | |
tree | ff302df77417456ee4dcf94082b6d942e320b13a /Lib/test/test_asyncio | |
parent | 618b7a8260bb40290d6551f24885931077309590 (diff) | |
download | cpython-0ca67e6313c11263ecaef7ce182308eeb5aa6814.zip cpython-0ca67e6313c11263ecaef7ce182308eeb5aa6814.tar.gz cpython-0ca67e6313c11263ecaef7ce182308eeb5aa6814.tar.bz2 |
GH-84559: Deprecate fork being the multiprocessing default. (#100618)
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() or concurrent.futures.ProcessPool use.
See the related issue and documentation within this change for details.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_events.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 214544b..b906905 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -4,6 +4,7 @@ import collections.abc import concurrent.futures import functools import io +import multiprocessing import os import platform import re @@ -2762,7 +2763,13 @@ class GetEventLoopTestsMixin: support.skip_if_broken_multiprocessing_synchronize() async def main(): - pool = concurrent.futures.ProcessPoolExecutor() + if multiprocessing.get_start_method() == 'fork': + # Avoid 'fork' DeprecationWarning. + mp_context = multiprocessing.get_context('forkserver') + else: + mp_context = None + pool = concurrent.futures.ProcessPoolExecutor( + mp_context=mp_context) result = await self.loop.run_in_executor( pool, _test_get_event_loop_new_process__sub_proc) pool.shutdown() |