Skip to content

gh-132561: Fix the public multiprocessing.SemLock.locked method - #132586

Merged
vstinner merged 10 commits into
python:mainfrom
YvesDup:sem-macosx-multiprocessing-locked
Apr 17, 2025
Merged

gh-132561: Fix the public multiprocessing.SemLock.locked method#132586
vstinner merged 10 commits into
python:mainfrom
YvesDup:sem-macosx-multiprocessing-locked

Conversation

@YvesDup

@YvesDupYvesDup commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

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

Comment threadLib/multiprocessing/synchronize.py Outdated
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment threadLib/test/_test_multiprocessing.py

@sobolevnsobolevn left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@vstinnervstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@vstinner
vstinner merged commit 15c75d7 into python:mainApr 17, 2025
@vstinner

Copy link
Copy Markdown
Member

Merged, thanks for the fix.

@YvesDup

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@chris-eibl

chris-eibl commented Apr 19, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@YvesDup

YvesDup commented Apr 19, 2025

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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