diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -105,6 +105,10 @@ except: MAXFD = 256 + +# An upper bound on the maximum number of semaphores needed by this test. +MAX_SEMS = 30 + # # Some tests require ctypes # @@ -115,6 +119,21 @@ Structure = object c_int = c_double = None + +def check_enough_semaphores(): + """Check that the system supports enough semaphores to run the test.""" + sems = [] + for i in range(MAX_SEMS): + try: + sem = multiprocessing.Semaphore() + sems.append(sem) + except OSError as e: + if e.errno == errno.ENFILE: + raise unittest.SkipTest("The OS doesn't support enough semaphores " + "to run the test.") + raise + + # # Creates a wrapper for a function which records the time it takes to finish # @@ -2349,6 +2368,8 @@ except OSError: raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!") + check_enough_semaphores() + if run is None: from test.support import run_unittest as run