Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3be0095

Browse files
author
Charles-François Natali
committed
Issue #12156: Skip test_multiprocessing on systems which don't support enough
POSIX semaphores (among which FreeBSD < 8).
1 parent ab1d16b commit 3be0095

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lib/test/test_multiprocessing.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ def latin(s):
9898
Structure = object
9999
c_int = c_double = None
100100

101+
102+
def check_enough_semaphores():
103+
"""Check that the system supports enough semaphores to run the test."""
104+
# minimum number of semaphores available according to POSIX
105+
nsems_min = 256
106+
try:
107+
nsems = os.sysconf("SC_SEM_NSEMS_MAX")
108+
except (AttributeError, ValueError):
109+
# sysconf not available or setting not available
110+
return
111+
if nsems == -1 or nsems >= nsems_min:
112+
return
113+
raise unittest.SkipTest("The OS doesn't support enough semaphores "
114+
"to run the test (required: %d)." % nsems_min)
115+
116+
101117
#
102118
# Creates a wrapper for a function which records the time it takes to finish
103119
#
@@ -2294,6 +2310,8 @@ def test_main(run=None):
22942310
except OSError:
22952311
raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!")
22962312

2313+
check_enough_semaphores()
2314+
22972315
if run is None:
22982316
from test.support import run_unittest as run
22992317

0 commit comments

Comments
 (0)