[Python-checkins] bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)

Miss Islington (bot) webhook-mailer at python.org
Fri Jun 19 12:19:46 EDT 2020


https://github.com/python/cpython/commit/ec9bc2da421c456e416d991fd1fe79ac33344d9d
commit: ec9bc2da421c456e416d991fd1fe79ac33344d9d
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-06-19T09:19:38-07:00
summary:

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 at python.org>

files:
M Lib/test/support/__init__.py

diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index b75dbd214fe36..3d287a98ac22d 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -3383,7 +3383,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.
@@ -3393,10 +3393,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}")



More information about the Python-checkins mailing list