Skip to content

Commit bf2b65e

Browse files
authored
bpo-28668: test.support.requires_multiprocessing_queue is removed (GH-4560)
Skip tests with test.support.import_module('multiprocessing.synchronize') instead when the semaphore implementation is broken or missing.
1 parent a561862 commit bf2b65e

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

Lib/test/support/__init__.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@
8787
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
8888
"requires_IEEE_754", "skip_unless_xattr", "requires_zlib",
8989
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
90-
"check__all__", "requires_multiprocessing_queue",
91-
"skip_unless_bind_unix_socket",
90+
"check__all__", "skip_unless_bind_unix_socket",
9291
# sys
9392
"is_jython", "is_android", "check_impl_detail", "unix_shell",
9493
"setswitchinterval",
@@ -1791,22 +1790,6 @@ def impl_detail(msg=None, **guards):
17911790
msg = msg.format(' or '.join(guardnames))
17921791
return unittest.skip(msg)
17931792

1794-
_have_mp_queue = None
1795-
def requires_multiprocessing_queue(test):
1796-
"""Skip decorator for tests that use multiprocessing.Queue."""
1797-
global _have_mp_queue
1798-
if _have_mp_queue is None:
1799-
import multiprocessing
1800-
# Without a functioning shared semaphore implementation attempts to
1801-
# instantiate a Queue will result in an ImportError (issue #3770).
1802-
try:
1803-
multiprocessing.Queue()
1804-
_have_mp_queue = True
1805-
except ImportError:
1806-
_have_mp_queue = False
1807-
msg = "requires a functioning shared semaphore implementation"
1808-
return test if _have_mp_queue else unittest.skip(msg)(test)
1809-
18101793
def _parse_guards(guards):
18111794
# Returns a tuple ({platform_name: run_me}, default_value)
18121795
if not guards:

Lib/test/test_logging.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,9 +3211,11 @@ def test_handle_called_with_queue_queue(self, mock_handle):
32113211
self.assertEqual(mock_handle.call_count, 5 * self.repeat,
32123212
'correct number of handled log messages')
32133213

3214-
@support.requires_multiprocessing_queue
32153214
@patch.object(logging.handlers.QueueListener, 'handle')
32163215
def test_handle_called_with_mp_queue(self, mock_handle):
3216+
# Issue 28668: The multiprocessing (mp) module is not functional
3217+
# when the mp.synchronize module cannot be imported.
3218+
support.import_module('multiprocessing.synchronize')
32173219
for i in range(self.repeat):
32183220
log_queue = multiprocessing.Queue()
32193221
self.setup_and_log(log_queue, '%s_%s' % (self.id(), i))
@@ -3230,14 +3232,16 @@ def get_all_from_queue(log_queue):
32303232
except queue.Empty:
32313233
return []
32323234

3233-
@support.requires_multiprocessing_queue
32343235
def test_no_messages_in_queue_after_stop(self):
32353236
"""
32363237
Five messages are logged then the QueueListener is stopped. This
32373238
test then gets everything off the queue. Failure of this test
32383239
indicates that messages were not registered on the queue until
32393240
_after_ the QueueListener stopped.
32403241
"""
3242+
# Issue 28668: The multiprocessing (mp) module is not functional
3243+
# when the mp.synchronize module cannot be imported.
3244+
support.import_module('multiprocessing.synchronize')
32413245
for i in range(self.repeat):
32423246
queue = multiprocessing.Queue()
32433247
self.setup_and_log(queue, '%s_%s' %(self.id(), i))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test.support.requires_multiprocessing_queue is removed. Skip tests with
2+
test.support.import_module('multiprocessing.synchronize') instead when the
3+
semaphore implementation is broken or missing.

0 commit comments

Comments
 (0)