Skip to content

Commit

Permalink
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (G…
Browse files Browse the repository at this point in the history
…H-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 3358da4)

Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
miss-islington and vstinner committed Jun 19, 2020
1 parent 83e54de commit 1529322
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Lib/test/support/__init__.py
Expand Up @@ -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.
Expand All @@ -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}")

0 comments on commit 1529322

Please sign in to comment.