Skip to main content

trampoline

Function trampoline 

Source
pub(crate) unsafe fn trampoline<F, R>(body: F) -> R
where F: for<'py> FnOnce(Python<'py>) -> PyResult<R> + UnwindSafe, R: PyCallbackOutput,
Expand description

Implementation of trampoline functions, which sets up an AttachGuard and calls F.

Panics during execution are trapped so that they don’t propagate through any outer FFI boundary.

§Safety

The thread must already be attached to the interpreter when this is called.

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here