8000 bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS … · python/cpython@3358da4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3358da4

Browse files
authored
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)
skip_if_broken_multiprocessing_synchronize() only attempts for create a semaphore on Linux to fix multiprocessing test_resource_tracker_reused() on macOS.
1 parent ec68918 commit 3358da4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Lib/test/support/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ def skip_if_broken_multiprocessing_synchronize():
19621962
"""
19631963
Skip tests if the multiprocessing.synchronize module is missing, if there
19641964
is no available semaphore implementation, or if creating a lock raises an
1965-
OSError.
1965+
OSError (on Linux only).
19661966
"""
19671967

19681968
# Skip tests if the _multiprocessing extension is missing.
@@ -1972,10 +1972,11 @@ def skip_if_broken_multiprocessing_synchronize():
19721972
# multiprocessing.synchronize requires _multiprocessing.SemLock.
19731973
synchronize = import_module('multiprocessing.synchronize')
19741974

1975-
try:
1976-
# bpo-38377: On Linux, creating a semaphore is the current user
1977-
# does not have the permission to create a file in /dev/shm.
1978-
# Create a semaphore to check permissions.
1979-
synchronize.Lock(ctx=None)
1980-
except OSError as exc:
1981-
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")
1975+
if sys.platform == "linux":
1976+
try:
1977+
# bpo-38377: On Linux, creating a semaphore fails with OSError
1978+
# if the current user does not have the permission to create
1979+
# a file in /dev/shm/ directory.
1980+
synchronize.Lock(ctx=None)
1981+
except OSError as exc:
1982+
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")

0 commit comments

Comments
 (0)
0