Function run_until_complete

Source
pub fn run_until_complete<R, F, T>(
    event_loop: &Bound<'_, PyAny>,
    fut: F,
) -> PyResult<T>
where R: Runtime + ContextExt, F: Future<Output = PyResult<T>> + Send + 'static, T: Send + Sync + 'static,
Expand description

Run the event loop until the given Future completes

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

§Arguments

  • event_loop - The Python event loop that should run the future
  • fut - The future to drive to completion

§Examples

pyo3_async_runtimes::generic::run_until_complete::<MyCustomRuntime, _, _>(&event_loop, async move {
    tokio::time::sleep(Duration::from_secs(1)).await;
    Ok(())
})?;