Function pyo3_asyncio::generic::run_until_complete[][src]

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

Run the event loop until the given Future completes

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

Arguments

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

Examples

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