Skip to content

gh-126316: Use mutexes in the grp module - #126504

Closed
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:grp_mutex
Closed

gh-126316: Use mutexes in the grp module#126504
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:grp_mutex

Conversation

@vstinner

@vstinnervstinner commented Nov 6, 2024

Copy link
Copy Markdown
Member

@vstinnervstinner added the needs backport to 3.13 bugs and security fixes label Nov 6, 2024
@bedevere-appbedevere-appBot mentioned this pull request Nov 6, 2024
Comment threadMisc/NEWS.d/next/Library/2024-11-06-15-23-29.gh-issue-126316.xBcDse.rst Outdated
@ZeroIntensity

Copy link
Copy Markdown
Member

Actually, we'll need a separate fix for subinterpreters on 3.12, because there's no PyMutex there.

…BcDse.rst
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@vstinner

Copy link
Copy Markdown
MemberAuthor

Actually, we'll need a separate fix for subinterpreters on 3.12, because there's no PyMutex there.

The regular build (not Free Threaded build) is not affected by #126316 since function calls are serialized by the GIL.

@ZeroIntensity

Copy link
Copy Markdown
Member

Yeah, but a subinterpreter can have its own GIL, so if these functions aren't thread safe on a system level, then it won't be thread safe across multiple interpreters. I think we just need to add a Py_mod_multiple_interpreters module slot with Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED, to indicate that subinterpreters need to use a shared GIL to use the module.

@vstinner

Copy link
Copy Markdown
MemberAuthor

Yeah, but a subinterpreter can have its own GIL, so if these functions aren't thread safe on a system level, then it won't be thread safe across multiple interpreters.

My change only fix free-threaded build. Should I also change the regular build for this use case?

@ZeroIntensity

Copy link
Copy Markdown
Member

On second thought, I think we should address subinterpreters in another PR for backporting reasons. The fix is what I said with the module slot above.

@vstinner

Copy link
Copy Markdown
MemberAuthor

#127055 was merged instead. I close this issue.

@vstinner
vstinner deleted the grp_mutex branch November 21, 2024 14:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@vstinner@ZeroIntensity