"""
Skip tests if the multiprocessing.synchronize module is missing, if there
is no available semaphore implementation, or if creating a lock raises an
- OSError.
+ OSError (on Linux only).
"""
# Skip tests if the _multiprocessing extension is missing.
# multiprocessing.synchronize requires _multiprocessing.SemLock.
synchronize = import_module('multiprocessing.synchronize')
- try:
- # bpo-38377: On Linux, creating a semaphore is the current user
- # does not have the permission to create a file in /dev/shm.
- # Create a semaphore to check permissions.
- synchronize.Lock(ctx=None)
- except OSError as exc:
- raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")
+ if sys.platform == "linux":
+ try:
+ # bpo-38377: On Linux, creating a semaphore fails with OSError
+ # if the current user does not have the permission to create
+ # a file in /dev/shm/ directory.
+ synchronize.Lock(ctx=None)
+ except OSError as exc:
+ raise unittest.SkipTest(f"broken multiprocessing SemLock: {exc!r}")