Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
Due of absence of thesem_getvalue C function in the MacOSX semaphore implementation,Lock andRLock representation strings are invalid in themultiprocessing module.
Call toself._semlock._get_value() raises an exception, and set part of repr with'unknown'.
importmultiprocessingasmpprint(mp.Lock()# <Lock(owner=unknown)> vs <Lock(owner=None)> on Linuxprint(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:
| elifself._semlock._get_value()==1: |
| elifself._semlock._get_value()==1: |
withelif 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