INNER CODE UNIT · Rust

to_py

apitap/apitap-lib · py-apitap/src/lib.rs:39

fn to_py(e: apitap_core::Error) -> PyErr {
    match e {
        apitap_core::Error::InvalidInput(m) => PyValueError::new_err(m),
        // Re-prefixed rather than passed bare: `Locked`'s Display is
        // "locked: {0}", and anything already matching that text keeps working.
        apitap_core::Error::Locked(m) => LockedError::new_err(format!("locked: {m}")),
        e => PyRuntimeError::new_err(e.to_string()),
    }
}

/// One shared multi-thread runtime for every call (building one per call would pay
/// thread-spawn latency each time).
fn rt() -> &'static Runtime {
    static RT: OnceLock<Runtime> = OnceLock::new();
    RT.get_or_init(|| Runtime::new().expect("tokio runtime"))
}

/// log_based rides a fresh current_thread runtime on the CALLING thread

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…