mirror of https://github.com/python/cpython.git
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.
This commit is contained in:
parent
dbb6e22cb1
commit
d46d3f2ec7
|
@ -21,22 +21,21 @@
|
||||||
from . import process
|
from . import process
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
# Try to import the mp.synchronize module cleanly, if it fails
|
# TODO: Do any platforms still lack a functioning sem_open?
|
||||||
# raise ImportError for platforms lacking a working sem_open implementation.
|
|
||||||
# See issue 3770
|
|
||||||
try:
|
try:
|
||||||
from _multiprocessing import SemLock, sem_unlink
|
from _multiprocessing import SemLock, sem_unlink
|
||||||
except (ImportError):
|
except ImportError:
|
||||||
raise ImportError("This platform lacks a functioning sem_open" +
|
raise ImportError("This platform lacks a functioning sem_open" +
|
||||||
" implementation, therefore, the required" +
|
" implementation. https://github.com/python/cpython/issues/48020.")
|
||||||
" synchronization primitives needed will not" +
|
|
||||||
" function, see issue 3770.")
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Constants
|
# 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
|
SEM_VALUE_MAX = _multiprocessing.SemLock.SEM_VALUE_MAX
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#ifdef HAVE_MP_SEMAPHORE
|
#ifdef HAVE_MP_SEMAPHORE
|
||||||
|
|
||||||
|
// These match the values in Lib/multiprocessing/synchronize.py
|
||||||
enum { RECURSIVE_MUTEX, SEMAPHORE };
|
enum { RECURSIVE_MUTEX, SEMAPHORE };
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue