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

RAII type that represents the Global Interpreter Lock acquisition.

Example

use cpython::Python;

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

Implementations

Acquires the global interpreter lock, which allows access to the Python runtime.

If the Python runtime is not already initialized, this function will initialize it. See prepare_freethreaded_python() for details.

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

Checks if the current thread holds the GIL.

This method is only available with Python 3.

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.