Skip to content

Migrate from PyGILState_Check to thread state checks internally #128360

Closed
@ZeroIntensity

Description

@ZeroIntensity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions