Debian Codegraph @

examples/async_std.rs

raw symbols SCIP
1 use pyo3::prelude::*;
2
3 #[pyo3_async_runtimes::async_std::main]
4 async fn main() -> PyResult<()> {
5 let fut = Python::attach(|py| {
6 let asyncio = py.import("asyncio")?;
7
8 // convert asyncio.sleep into a Rust Future
9 pyo3_async_runtimes::async_std::into_future(asyncio.call_method1("sleep", (1,))?)
10 })?;
11
12 println!("sleeping for 1s");
13 fut.await?;
14 println!("done");
15
16 Ok(())
17 }