summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalcolm Smith <smith@chaquo.com>2024-02-25 19:38:18 (GMT)
committerGitHub <noreply@github.com>2024-02-25 19:38:18 (GMT)
commit4827968af87d828554c3fadd97094c97798541b4 (patch)
tree162bb428457003ea4451e1f98d7e12ef352b48e5
parentc40b5b97fdac5099f670589b42c9038d7b23f2e5 (diff)
downloadcpython-4827968af87d828554c3fadd97094c97798541b4.zip
cpython-4827968af87d828554c3fadd97094c97798541b4.tar.gz
cpython-4827968af87d828554c3fadd97094c97798541b4.tar.bz2
gh-71052: Enable test_concurrent_futures on platforms that lack multiprocessing (gh-115917)
Enable test_concurrent_futures on platforms that support threading but not multiprocessing.
-rw-r--r--Lib/multiprocessing/queues.py2
-rw-r--r--Lib/test/test___all__.py16
-rw-r--r--Lib/test/test_concurrent_futures/__init__.py2
-rw-r--r--Lib/test/test_concurrent_futures/test_init.py7
-rw-r--r--Lib/test/test_concurrent_futures/util.py8
-rw-r--r--Misc/NEWS.d/next/Tests/2024-02-25-15-58-28.gh-issue-71052.lxBjqY.rst2
6 files changed, 16 insertions, 21 deletions
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 852ae87..925f043 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -20,8 +20,6 @@ import errno
from queue import Empty, Full
-import _multiprocessing
-
from . import connection
from . import context
_ForkingPickler = context.reduction.ForkingPickler
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index c87cde4..19dcbb2 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -5,11 +5,6 @@ import os
import sys
import types
-try:
- import _multiprocessing
-except ModuleNotFoundError:
- _multiprocessing = None
-
if support.check_sanitizer(address=True, memory=True):
SKIP_MODULES = frozenset((
@@ -36,17 +31,6 @@ class FailedImport(RuntimeError):
class AllTest(unittest.TestCase):
- def setUp(self):
- # concurrent.futures uses a __getattr__ hook. Its __all__ triggers
- # import of a submodule, which fails when _multiprocessing is not
- # available.
- if _multiprocessing is None:
- sys.modules["_multiprocessing"] = types.ModuleType("_multiprocessing")
-
- def tearDown(self):
- if _multiprocessing is None:
- sys.modules.pop("_multiprocessing")
-
def check_all(self, modname):
names = {}
with warnings_helper.check_warnings(
diff --git a/Lib/test/test_concurrent_futures/__init__.py b/Lib/test/test_concurrent_futures/__init__.py
index 430fa93..17a2853 100644
--- a/Lib/test/test_concurrent_futures/__init__.py
+++ b/Lib/test/test_concurrent_futures/__init__.py
@@ -3,8 +3,6 @@ import unittest
from test import support
from test.support import import_helper
-# Skip tests if _multiprocessing wasn't built.
-import_helper.import_module('_multiprocessing')
if support.check_sanitizer(address=True, memory=True):
# gh-90791: Skip the test because it is too slow when Python is built
diff --git a/Lib/test/test_concurrent_futures/test_init.py b/Lib/test/test_concurrent_futures/test_init.py
index d79a636..113a4d1 100644
--- a/Lib/test/test_concurrent_futures/test_init.py
+++ b/Lib/test/test_concurrent_futures/test_init.py
@@ -5,6 +5,8 @@ import time
import unittest
import sys
from concurrent.futures._base import BrokenExecutor
+from concurrent.futures.process import _check_system_limits
+
from logging.handlers import QueueHandler
from test import support
@@ -117,6 +119,11 @@ class FailingInitializerResourcesTest(unittest.TestCase):
"""
def _test(self, test_class):
+ try:
+ _check_system_limits()
+ except NotImplementedError:
+ self.skipTest("ProcessPoolExecutor unavailable on this system")
+
runner = unittest.TextTestRunner()
runner.run(test_class('test_initializer'))
diff --git a/Lib/test/test_concurrent_futures/util.py b/Lib/test/test_concurrent_futures/util.py
index dc48bec..3e85503 100644
--- a/Lib/test/test_concurrent_futures/util.py
+++ b/Lib/test/test_concurrent_futures/util.py
@@ -136,6 +136,12 @@ def create_executor_tests(remote_globals, mixin, bases=(BaseTestCase,),
def setup_module():
- unittest.addModuleCleanup(multiprocessing.util._cleanup_tests)
+ try:
+ _check_system_limits()
+ except NotImplementedError:
+ pass
+ else:
+ unittest.addModuleCleanup(multiprocessing.util._cleanup_tests)
+
thread_info = threading_helper.threading_setup()
unittest.addModuleCleanup(threading_helper.threading_cleanup, *thread_info)
diff --git a/Misc/NEWS.d/next/Tests/2024-02-25-15-58-28.gh-issue-71052.lxBjqY.rst b/Misc/NEWS.d/next/Tests/2024-02-25-15-58-28.gh-issue-71052.lxBjqY.rst
new file mode 100644
index 0000000..8bac68b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-02-25-15-58-28.gh-issue-71052.lxBjqY.rst
@@ -0,0 +1,2 @@
+Enable ``test_concurrent_futures`` on platforms that support threading but not
+multiprocessing.