MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / acquire

Method acquire

src/pythonrun.rs:115–124  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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]

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected