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

Skip to content 8000

Commit ec9bc2d

Browse files
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. (cherry picked from commit 3358da4) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 4dd10ed commit ec9bc2d

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
@@ -3383,7 +3383,7 @@ def skip_if_broken_multipro CBAD cessing_synchronize():
33833383
"""
33843384
Skip tests if the multiprocessing.synchronize module is missing, if there
33853385
is no available semaphore implementation, or if creating a lock raises an
3386-
OSError.
3386+
OSError (on Linux only).
33873387
"""
33883388

33893389
# Skip tests if the _multiprocessing extension is missing.
@@ -3393,10 +3393,11 @@ def skip_if_broken_multiprocessing_synchronize():
33933393
# multiprocessing.synchronize requires _multiprocessing.SemLock.
33943394
synchronize = import_module('multiprocessing.synchronize')
33953395

3396-
try:
3397-
# bpo-38377: On Linux, creating a semaphore is the current user
3398-
# does not have the permission to create a file in /dev/shm.
3399-
# Create a semaphore to check permissions.
3400-
synchronize.Lock(ctx=None)
3401-
except OSError as exc:
3402-
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")
3396+
if sys.platform == "linux":
3397+
try:
3398+
# bpo-38377: On Linux, creating a semaphore fails with OSError
3399+
# if the current user does not have the permission to create
3400+
# a file in /dev/shm/ directory.
3401+
synchronize.Lock(ctx=None)
3402+
except OSError as exc:
3403+
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")

0 commit comments

Comments
 (0)
0