with_critical_section2

Function with_critical_section2 

Source
pub fn with_critical_section2<F, R>(
    a: &Bound<'_, PyAny>,
    b: &Bound<'_, PyAny>,
    f: F,
) -> R
where F: FnOnce() -> R,
Expand description

Executes a closure with a Python critical section held on two objects.

Locks the per-object mutex for the objects a and b that are 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_SECTION2 and Py_END_CRITICAL_SECTION2 C-API macros.