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:
|
elif self._semlock._get_value() == 1: |
|
elif self._semlock._get_value() == 1: |
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
Bug report
Bug description:
Due of absence of the
sem_getvalueC function in the MacOSX semaphore implementation,LockandRLockrepresentation strings are invalid in themultiprocessingmodule.Call to
self._semlock._get_value()raises an exception, and set part of repr with 'unknown'.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