Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiprocessing Lock and RLock - invalid representation string on MacOSX. #125679

Open
YvesDup opened this issue Oct 18, 2024 · 0 comments
Open
Labels
stdlib Python modules in the Lib dir topic-multiprocessing type-bug An unexpected behavior, bug, or error

Comments

@YvesDup
Copy link
Contributor

YvesDup commented Oct 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-multiprocessing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants