pub fn monarch_with_gil_blocking<F, R>(site: GilSite, f: F) -> Rwhere
F: for<'py> FnOnce(Python<'py>) -> R,Expand description
Blocking wrapper around Python::with_gil for use in synchronous contexts.
Unlike monarch_with_gil, this function does NOT use the GIL_LOCK async mutex.
Since it is blocking call, it simply acquires the GIL and releases it when the
closure returns.
Note: like monarch_with_gil, the control-plane GIL accounting
(check_gil_site) covers only acquisitions that route through these wrappers;
a raw Python::attach elsewhere bypasses it.
§Example
ⓘ
let result = monarch_with_gil_blocking(GilSite::Convert, |py| {
// Do work with Python GIL
Ok(42)
})?;