-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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 LinuxI propose to replace in the __repr__ method of each class the following test:
cpython/Lib/multiprocessing/synchronize.py
Line 177 in 37e533a
| elif self._semlock._get_value() == 1: |
cpython/Lib/multiprocessing/synchronize.py
Line 203 in 37e533a
| 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
- 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
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error