diff options
author | Gregory P. Smith <greg@krypto.org> | 2024-11-07 00:06:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-07 00:06:14 -0800 |
commit | d46d3f2ec783004f0927c9f5e6211a570360cf3b (patch) | |
tree | 51a6b7c237eb1d6888f7385b15c1e21095c5b293 /Lib/multiprocessing/synchronize.py | |
parent | dbb6e22cb1f533bba00a61a5b63ec68af9d48836 (diff) | |
download | cpython-d46d3f2ec783004f0927c9f5e6211a570360cf3b.tar.gz cpython-d46d3f2ec783004f0927c9f5e6211a570360cf3b.zip |
Cleanup multiprocessing comment and unusual import error message (#126532)
Define constants as constants rather than calling `list(range(2))`.
Explain which values must remain in sync via comments.
Diffstat (limited to 'Lib/multiprocessing/synchronize.py')
-rw-r--r-- | Lib/multiprocessing/synchronize.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py index 3ccbfe311c7..1917a8bd51d 100644 --- a/Lib/multiprocessing/synchronize.py +++ b/Lib/multiprocessing/synchronize.py @@ -21,22 +21,21 @@ from . import context from . import process from . import util -# Try to import the mp.synchronize module cleanly, if it fails -# raise ImportError for platforms lacking a working sem_open implementation. -# See issue 3770 +# TODO: Do any platforms still lack a functioning sem_open? try: from _multiprocessing import SemLock, sem_unlink -except (ImportError): +except ImportError: raise ImportError("This platform lacks a functioning sem_open" + - " implementation, therefore, the required" + - " synchronization primitives needed will not" + - " function, see issue 3770.") + " implementation. https://github.com/python/cpython/issues/48020.") # # Constants # -RECURSIVE_MUTEX, SEMAPHORE = list(range(2)) +# These match the enum in Modules/_multiprocessing/semaphore.c +RECURSIVE_MUTEX = 0 +SEMAPHORE = 1 + SEM_VALUE_MAX = _multiprocessing.SemLock.SEM_VALUE_MAX # |