summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-06-19 16:20:15 (GMT)
committerGitHub <noreply@github.com>2020-06-19 16:20:15 (GMT)
commit1529322ca6b7b029af65aceeb04e6d47013eeeb4 (patch)
tree7ba0e2ad6db03f2e53b2bc58690733619c067704
parent83e54debac6344818bd9ee171314869d0ac024dd (diff)
downloadcpython-1529322ca6b7b029af65aceeb04e6d47013eeeb4.zip
cpython-1529322ca6b7b029af65aceeb04e6d47013eeeb4.tar.gz
cpython-1529322ca6b7b029af65aceeb04e6d47013eeeb4.tar.bz2
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 3358da4054b9b0b045eb47dc74dee3d58bfbb1d5) Co-authored-by: Victor Stinner <vstinner@python.org>
-rw-r--r--Lib/test/support/__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 28738da..9fad3f0 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -3174,7 +3174,7 @@ def skip_if_broken_multiprocessing_synchronize():
"""
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.
@@ -3184,10 +3184,11 @@ def skip_if_broken_multiprocessing_synchronize():
# 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}")