Skip to main content

spawn_blocking_with_timeout

Function spawn_blocking_with_timeout 

Source
pub async fn spawn_blocking_with_timeout<T: Send + 'static>(
    timeout: Duration,
    f: impl FnOnce() -> Result<T> + Send + 'static,
) -> Result<T>
Expand description

On timeout the blocking task is detached, not cancelled — a blocking syscall cannot be aborted, so anything the closure captures (e.g. a tempfile::TempPath whose drop removes the temporary file) is released only when the syscall eventually returns.