Skip to content

Commit 0f945f2

Browse files
gh-159689: Skip sentinel pipe tests when multiprocessing is unavailable
1 parent 5626bf2 commit 0f945f2

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

‎Lib/test/test_concurrent_futures/test_process_pool.py‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import unittest.mock
1212
import weakref
1313
from concurrent import futures
14-
from concurrent.futures.process import BrokenProcessPool
14+
from concurrent.futures.process import BrokenProcessPool, _check_system_limits
1515

1616
from test import support
1717
from test.support import hashlib_helper, threading_helper, warnings_helper
@@ -616,33 +616,45 @@ class ResultPipeSentinelTest(BaseTestCase):
616616
ProcessPoolExecutor's result queue is set up. gh-159689.
617617
"""
618618

619+
def setUp(self):
620+
super().setUp()
621+
try:
622+
_check_system_limits()
623+
except NotImplementedError:
624+
self.skipTest("ProcessPoolExecutor unavailable on this system")
625+
619626
def _context(self):
620627
return mp.get_context("spawn")
621628

622629
def test_partial_message_raises_when_writer_exits(self):
623630
ctx = self._context()
624631
reader, writer = ctx.Pipe(duplex=False)
625632
proc = ctx.Process(target=_send_result_header_only, args=(writer,))
633+
started = False
626634
try:
627635
proc.start()
636+
started = True
628637
proc.join(support.SHORT_TIMEOUT)
629638
self.assertEqual(proc.exitcode, 0)
630-
started = time.monotonic()
639+
t0 = time.monotonic()
631640
with self.assertRaises(mp.connection._SentinelReady):
632641
reader.recv(sentinels=[proc.sentinel])
633-
self.assertLess(time.monotonic() - started, support.SHORT_TIMEOUT)
642+
self.assertLess(time.monotonic() - t0, support.SHORT_TIMEOUT)
634643
finally:
635644
writer.close()
636645
reader.close()
637-
proc.join(support.SHORT_TIMEOUT)
638-
proc.close()
646+
if started:
647+
proc.join(support.SHORT_TIMEOUT)
648+
proc.close()
639649

640650
def test_complete_message_still_received(self):
641651
ctx = self._context()
642652
reader, writer = ctx.Pipe(duplex=False)
643653
proc = ctx.Process(target=_send_object, args=(writer,))
654+
started = False
644655
try:
645656
proc.start()
657+
started = True
646658
proc.join(support.SHORT_TIMEOUT)
647659
self.assertEqual(proc.exitcode, 0)
648660
writer.close()
@@ -651,8 +663,9 @@ def test_complete_message_still_received(self):
651663
finally:
652664
writer.close()
653665
reader.close()
654-
proc.join(support.SHORT_TIMEOUT)
655-
proc.close()
666+
if started:
667+
proc.join(support.SHORT_TIMEOUT)
668+
proc.close()
656669

657670

658671
create_executor_tests(globals(), ProcessPoolExecutorTest,

0 commit comments

Comments
 (0)