diff options
author | Victor Stinner <vstinner@python.org> | 2020-06-19 16:01:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-19 16:01:20 (GMT) |
commit | 3358da4054b9b0b045eb47dc74dee3d58bfbb1d5 (patch) | |
tree | 7797dfcd8acb68d8b74c87fc5e7da23992e3a2c1 /Lib/test/support | |
parent | ec689187957cc80af56b9a63251bbc295bafd781 (diff) | |
download | cpython-3358da4054b9b0b045eb47dc74dee3d58bfbb1d5.zip cpython-3358da4054b9b0b045eb47dc74dee3d58bfbb1d5.tar.gz cpython-3358da4054b9b0b045eb47dc74dee3d58bfbb1d5.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.
Diffstat (limited to 'Lib/test/support')
-rw-r--r-- | Lib/test/support/__init__.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index d9dbdc1..bceb8cd 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1962,7 +1962,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. @@ -1972,10 +1972,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}") |