pub struct GILGuard { /* private fields */ }
Expand description

RAII type that represents the Global Interpreter Lock acquisition.

Users are strongly encouraged to use Python::with_gil instead of directly constructing this type. See Python::acquire_gil for more.

Examples

use pyo3::Python;

{
    let gil_guard = Python::acquire_gil();
    let py = gil_guard.python();
} // GIL is released when gil_guard is dropped

Implementations

Retrieves the marker type that proves that the GIL was acquired.

Trait Implementations

The Drop implementation for GILGuard will release the GIL.

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.