Trait MutexExt

Source
pub trait MutexExt<T>: Sealed {
    // Required method
    fn lock_py_attached(&self, py: Python<'_>) -> LockResult<MutexGuard<'_, T>>;
}
Expand description

Extension trait for std::sync::Mutex which helps avoid deadlocks between the Python interpreter and acquiring the Mutex.

Required Methods§

Source

fn lock_py_attached(&self, py: Python<'_>) -> LockResult<MutexGuard<'_, T>>

Lock this Mutex in a manner that cannot deadlock with the Python interpreter.

Before attempting to lock the mutex, this function detaches from the Python runtime. When the lock is acquired, it re-attaches to the Python runtime before returning the LockResult. This avoids deadlocks between the GIL and other global synchronization events triggered by the Python interpreter.

Implementations on Foreign Types§

Source§

impl<T> MutexExt<T> for Mutex<T>

Source§

fn lock_py_attached(&self, _py: Python<'_>) -> LockResult<MutexGuard<'_, T>>

Implementors§