Function pyo3::gil::gil_is_acquired

source ·
fn gil_is_acquired() -> bool
Expand description

Checks whether the GIL is acquired.

Note: This uses pyo3’s internal count rather than PyGILState_Check for two reasons:

  1. for performance
  2. PyGILState_Check always returns 1 if the sub-interpreter APIs have ever been called, which could lead to incorrect conclusions that the GIL is held.
⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here