]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)
authorVictor Stinner <vstinner@python.org>
Fri, 19 Jun 2020 16:01:20 +0000 (18:01 +0200)
committerGitHub <noreply@github.com>
Fri, 19 Jun 2020 16:01:20 +0000 (18:01 +0200)
skip_if_broken_multiprocessing_synchronize() only attempts for create
a semaphore on Linux to fix multiprocessing
test_resource_tracker_reused() on macOS.

Lib/test/support/__init__.py

index d9dbdc13008dcc234f0cba03d2296cc2029cf2e2..bceb8cda20c35e5b9a741f56e31c3700d18f4bf1 100644 (file)
@@ -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}")