pub fn with_critical_section<F, R>(object: &Bound<'_, PyAny>, f: F) -> Rwhere
F: FnOnce() -> R,Expand description
Executes a closure with a Python critical section held on an object.
Locks the per-object mutex for the object op that is held while the closure f is
executing. The critical section may be temporarily released and re-acquired if the closure calls
back into the interpreter. See the notes in the
pyo3::sync::critical_section module documentation for more
details.
This is structurally equivalent to the use of the paired Py_BEGIN_CRITICAL_SECTION and Py_END_CRITICAL_SECTION C-API macros.