[][src]Function pyo3::prepare_freethreaded_python

pub fn prepare_freethreaded_python()

Prepares the use of Python in a free-threaded context.

If the Python interpreter is not already initialized, this function will initialize it with disabled signal handling (Python will not raise the KeyboardInterrupt exception). Python signal handling depends on the notion of a 'main thread', which must be the thread that initializes the Python interpreter.

If both the Python interpreter and Python threading are already initialized, this function has no effect.

Panic

If the Python interpreter is initialized but Python threading is not, a panic occurs. It is not possible to safely access the Python runtime unless the main thread (the thread which originally initialized Python) also initializes threading.

When writing an extension module, the #[pymodule] macro will ensure that Python threading is initialized.