8000 gh-71052: Enable test_concurrent_futures on platforms that lack multi… · python/cpython@4827968 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4827968

Browse files
authored
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.
1 parent c40b5b9 commit 4827968

File tree

6 files changed

+16
-21
lines changed

Lib/multiprocessing/queues.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
from queue import Empty, Full
2222

23-
import _multiprocessing
24-
2523
from . import connection
2624
from . import context
2725
_ForkingPickler = context.reduction.ForkingPickler

Lib/test/test___all__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import sys
66
import types
77

8-
try:
9-
import _multiprocessing
10-
except ModuleNotFoundError:
11-
_multiprocessing = None
12-
138

149
if support.check_sanitizer(address=True, memory=True):
1510
SKIP_MODULES = frozenset((
@@ -36,17 +31,6 @@ class FailedImport(RuntimeError):
3631

3732
class AllTest(unittest.TestCase):
3833

39-
def setUp(self):
40-
# concurrent.futures uses a __getattr__ hook. Its __all__ triggers
41-
# import of a submodule, which fails when _multiprocessing is not
42-
# available.
43-
if _multiprocessing is None:
44-
sys.modules["_multiprocessing"] = types.ModuleType("_multiprocessing")
45-
46-
def tearDown(self):
47-
if _multiprocessing is None:
48-
sys.modules.pop("_multiprocessing")
49-
5034
def check_all(self, modname):
5135
names = {}
5236
with warnings_helper.check_warnings(

Lib/test/test_concurrent_futures/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from test import support
44
from test.support import import_helper
55

6-
# Skip tests if _multiprocessing wasn't built.
7-
import_helper.import_module('_multiprocessing')
86

97
if support.check_sanitizer(address=True, memory=True):
108
# gh-90791: Skip the test because it is too slow when Python is built

Lib/test/test_concurrent_futures/test_init.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import unittest
66
import sys
77
from concurrent.futures._base import BrokenExecutor
8+
from concurrent.futures.process import _check_system_limits
9+
810
from logging.handlers import QueueHandler
911

1012
from test import support
@@ -117,6 +119,11 @@ class FailingInitializerResourcesTest(unittest.TestCase):
117119
"""
118120

119121
def _test(self, test_class):
122+
try:
123+
_check_system_limits()
124+
except NotImplementedError:
125+
self.skipTest("ProcessPoolExecutor unavailable on this system")
126+
120127
runner = unittest.TextTestRunner()
121128
runner.run(test_class('test_initializer'))
122129

Lib/test/test_concurrent_futures/util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ def strip_mixin(name):
136136

137137

138138
def setup_module():
139-
unittest.addModuleCleanup(multiprocessing.util._cleanup_tests)
139+
try:
140+
_check_system_limits()
141+
except NotImplementedError:
142+
pass
143+
else:
144+
unittest.addModuleCleanup(multiprocessing.util._cleanup_tests)
145+
140146
thread_info = threading_helper.threading_setup()
141147
unittest.addModuleCleanup(threading_helper.threading_cleanup, *thread_info)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Enable ``test_concurrent_futures`` on platforms that support threading but not
2+
multiprocessing.

0 commit comments

Comments
 (0)
0