run_until_complete in pyo3_asyncio::async_std - Rust (original) (raw)

Function run_until_complete

Source

pub fn run_until_complete<F, T>(event_loop: &PyAny, fut: F) -> PyResult<T>

where
    F: Future<Output = PyResult<T>> + Send + 'static,
    T: Send + Sync + 'static,

Expand description

Run the event loop until the given Future completes

The event loop runs until the given future is complete.

After this function returns, the event loop can be resumed with run_until_complete

§Arguments

§Examples

pyo3_asyncio::async_std::run_until_complete(event_loop, async move {
    async_std::task::sleep(Duration::from_secs(1)).await;
    Ok(())
})?;