pyo3-asyncio-0-21 0.21.0

PyO3 utilities for Python's Asyncio library - 0.21 fork
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use pyo3::prelude::*;

#[pyo3_asyncio_0_21::tokio::main(flavor = "multi_thread", worker_threads = 10)]
async fn main() -> PyResult<()> {
    let fut = Python::with_gil(|py| {
        let asyncio = py.import_bound("asyncio")?;

        // convert asyncio.sleep into a Rust Future
        pyo3_asyncio_0_21::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
    })?;

    println!("sleeping for 1s");
    fut.await?;
    println!("done");

    Ok(())
}