Skip to main content

reinit_thread_mutex_after_fork

Function reinit_thread_mutex_after_fork 

Source
pub unsafe fn reinit_thread_mutex_after_fork<T: ?Sized>(
    mutex: &PyThreadMutex<T>,
)
Expand description

Reset a PyThreadMutex to its initial (unlocked, unowned) state after fork().

PyThreadMutex is used by buffered IO objects (BufferedReader, BufferedWriter, TextIOWrapper). If a dead parent thread held one of these locks during fork(), the child would deadlock on any IO operation.

ยงSafety

Must only be called from the single-threaded child process immediately after fork(), before any other thread is created.