Skip to content

Commit 106fb85

Browse files
vstinnermiss-islington
authored andcommitted
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (pythonGH-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 <[email protected]>
1 parent 83e54de commit 106fb85

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
@@ -3174,7 +3174,7 @@ def skip_if_broken_multiprocessing_synchronize():
31743174
"""
31753175
Skip tests if the multiprocessing.synchronize module is missing, if there
31763176
is no available semaphore implementation, or if creating a lock raises an
3177-
OSError.
3177+
OSError (on Linux only).
31783178
"""
31793179

31803180
# Skip tests if the _multiprocessing extension is missing.
@@ -3184,10 +3184,11 @@ def skip_if_broken_multiprocessing_synchronize():
31843184
# multiprocessing.synchronize requires _multiprocessing.SemLock.
31853185
synchronize = import_module('multiprocessing.synchronize')
31863186

3187-
try:
3188-
# bpo-38377: On Linux, creating a semaphore is the current user
3189-
# does not have the permission to create a file in /dev/shm.
3190-
# Create a semaphore to check permissions.
3191-
synchronize.Lock(ctx=None)
3192-
except OSError as exc:
3193-
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")
3187+
if sys.platform == "linux":
3188+
try:
3189+
# bpo-38377: On Linux, creating a semaphore fails with OSError
3190+
# if the current user does not have the permission to create
3191+
# a file in /dev/shm/ directory.
3192+
synchronize.Lock(ctx=None)
3193+
except OSError as exc:
3194+
raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")

0 commit comments

Comments
 (0)