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()](fn.prepare_freethreaded_python.html) for details.
()
| 113 | /// If the Python runtime is not already initialized, this function will initialize it. |
| 114 | /// See [prepare_freethreaded_python()](fn.prepare_freethreaded_python.html) for details. |
| 115 | pub fn acquire() -> GILGuard { |
| 116 | if !cfg!(feature = "no-auto-initialize") { |
| 117 | crate::pythonrun::prepare_freethreaded_python(); |
| 118 | } |
| 119 | let gstate = unsafe { ffi::PyGILState_Ensure() }; // acquire GIL |
| 120 | GILGuard { |
| 121 | gstate, |
| 122 | no_send: marker::PhantomData, |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /// Retrieves the marker type that proves that the GIL was acquired. |
| 127 | #[inline] |
nothing calls this directly
no test coverage detected