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

Migrate from PyGILState_Check to thread state checks internally #128360

Open
ZeroIntensity opened this issue Dec 30, 2024 · 0 comments
Open

Migrate from PyGILState_Check to thread state checks internally #128360

ZeroIntensity opened this issue Dec 30, 2024 · 0 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-subinterpreters type-feature A feature request or enhancement

Comments

@ZeroIntensity
Copy link
Member

ZeroIntensity commented Dec 30, 2024

Feature or enhancement

Proposal:

In some older areas of the codebase, we have the following to ensure that the caller holds the GIL (or really, an attached thread state):

assert(PyGILState_Check())

This doesn't work for subinterpreters, because GILstate checks are disabled when subinterpreters exist. This hasn't been an issue in practice, but it would be nice to get these replaced with more correct thread state checks. I think a helper function that calls _Py_EnsureTstateNotNULL if assertions are enabled would work nicely.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-subinterpreters type-feature A feature request or enhancement
Projects
Status: Todo
Development

No branches or pull requests

1 participant