]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-71052: Enable test_concurrent_futures on platforms that lack multiprocessing ...
authorMalcolm Smith <smith@chaquo.com>
Sun, 25 Feb 2024 19:38:18 +0000 (19:38 +0000)
committerGitHub <noreply@github.com>
Sun, 25 Feb 2024 19:38:18 +0000 (11:38 -0800)
Enable test_concurrent_futures on platforms that support threading but not multiprocessing.

Lib/multiprocessing/queues.py
Lib/test/test___all__.py
Lib/test/test_concurrent_futures/__init__.py
Lib/test/test_concurrent_futures/test_init.py
Lib/test/test_concurrent_futures/util.py
Misc/NEWS.d/next/Tests/2024-02-25-15-58-28.gh-issue-71052.lxBjqY.rst [new file with mode: 0644]

index 852ae87b27686122a096dfa691c5364d87ebe8aa..925f043900004e732e72a5d629e6f9e0c2f2a3c3 100644 (file)
@@ -20,8 +20,6 @@ import errno
 
 from queue import Empty, Full
 
-import _multiprocessing
-
 from . import connection
 from . import context
 _ForkingPickler = context.reduction.ForkingPickler
index c87cde4b3d1fab19bf3a170dab9dd1f58217b37d..19dcbb207e914afe342a4c44d6cc4f38407b685b 100644 (file)
@@ -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(
index 430fa93aa456a2dfeed8ec1e38cd08c9a7dd61ac..17a2853173ba18aa8235096e60036c1e4a15948e 100644 (file)
@@ -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
index d79a6367701fb4b22d6d592d861cd8b51a3a6557..113a4d1c54be03b55eb674c9f537c6dafb129bee 100644 (file)
@@ -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'))
 
index dc48bec796b87fe12be1bffa43d2367b4ce19a41..3e855031913042f8c680a46923a54e59746ad746 100644 (file)
@@ -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 (file)
index 0000000..8bac68b
--- /dev/null
@@ -0,0 +1,2 @@
+Enable ``test_concurrent_futures`` on platforms that support threading but not
+multiprocessing.