Function pyo3_asyncio::async_std::re_exports::spawn_blocking
source · [−]pub fn spawn_blocking<F, T>(f: F) -> JoinHandle<T> where
F: 'static + FnOnce() -> T + Send,
T: 'static + Send,
Expand description
re-export spawn_blocking for use in #[test]
macro without external dependency
Spawns a blocking task.
The task will be spawned onto a thread pool specifically dedicated to blocking tasks. This is useful to prevent long-running synchronous operations from blocking the main futures executor.
See also: task::block_on
, task::spawn
.
Examples
Basic usage:
use async_std::task;
task::spawn_blocking(|| {
println!("long-running task here");
})
.await;