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

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

Examples

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