Skip to content

Conversation

@YvesDup
Copy link
Contributor

@YvesDupYvesDup commented Apr 16, 2025

Fix the public multiprocessing.SemLock.lockedmethod, add a docstring.
Add 2 tests for multiprocessing.Lock and multiprocessing.RLock.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @vstinner and @gpshead

Thanks again!

@vstinnervstinner removed the needs backport to 3.13 bugs and security fixes label Apr 17, 2025
@vstinner
Copy link
Member

Python 3.13 doesn't have the locked() method, it's a new feature in Python 3.14.

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinnervstinner merged commit 15c75d7 into python:mainApr 17, 2025
41 checks passed
@vstinner
Copy link
Member

Merged, thanks for the fix.

@YvesDup
Copy link
ContributorAuthor

Sorry for my late awaken , but as the locked method is defined in the multiprocessing.SemLock base class, should not we modify documentation for multiprocessing.[Bounded]Semaphore classes by adding an entry for this public method ?

@vstinner
Copy link
Member

If you consider that the doc is wrong, please go ahead and propose a doc change.

@chris-eibl
Copy link
Member

chris-eibl commented Apr 19, 2025

If my analysis is correct, this has broken the AMD64 FreeBSD14 3.x and AMD64 FreeBSD15 3.x build bots, see #132719 (comment).

@sobolevn
Copy link
Member

Thanks for the info! I will try to fix this ASAP :)

@YvesDup
Copy link
ContributorAuthor

YvesDup commented Apr 19, 2025

From https://buildbot.python.org/#/builders/1232/builds/5389/steps/6/logs/stdio

====================================================================== ERROR: test_rlock_locked_2processes (test.test_multiprocessing_fork.test_processes.WithProcessesTestLock.test_rlock_locked_2processes) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/_test_multiprocessing.py", line 1591, in test_rlock_locked_2processes res = Value('b', 0) ^^^^^ NameError: name 'Value' is not defined. Did you mean: 'self.Value'? 

See

res=Value('b', 0)

The fix should be: res = self.Value('b', 0)

I don't figure out why tests failed for AMD64 FreeBSD14 3.x and succeeded on Ubuntu.

Edit: I will send a fix tomorrow

@sobolevn
Copy link
Member

@YvesDup because of this line: from multiprocessing.sharedctypes import Value, copy
It is not always available :)

Please, send a PR.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@YvesDup@vstinner@chris-eibl@sobolevn@ZeroIntensity