Closed
Description
Bug report
Bug description:
Due of absence of the sem_getvalue
C function in the MacOSX semaphore implementation, Lock
and RLock
representation strings are invalid in the multiprocessing
module.
Call to self._semlock._get_value()
raises an exception, and set part of repr with 'unknown'.
import multiprocessing as mp
print(mp.Lock() # <Lock(owner=unknown)> vs <Lock(owner=None)> on Linux
print(mp.RLockj()) # <RLock(unknown, unknown)> vs <RLock(None, 0)> on Linux
I propose to replace in the __repr__
method of each class the following test:
cpython/Lib/multiprocessing/synchronize.py
Line 177 in 37e533a
cpython/Lib/multiprocessing/synchronize.py
Line 203 in 37e533a
with elif not self._semlock._is_zero():
.
This method is available and valid on each OS.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-125679: multiprocessing Lock and RLock - fix invalid representation string on MacOSX. #125680
- [3.13] gh-125679: multiprocessing Lock and RLock - fix invalid representation string on MacOSX. (GH-125680) #126533
- [3.12] gh-125679: multiprocessing Lock and RLock - fix invalid representation string on MacOSX. (GH-125680) #126534