Attribute Macro pyo3_asyncio::tokio::main
#[main]
Expand description
attributes
Enables an async main function that uses the tokio runtime.
Arguments
flavor
- selects the type of tokio runtime [“multi_thread”, “current_thread”]worker_threads
- number of worker threads, defaults to the number of CPUs on the system
Examples
Default configuration:
ⓘ
#[pyo3_asyncio::tokio::main]
async fn main() -> PyResult<()> {
Ok(())
}
Current-thread scheduler:
ⓘ
#[pyo3_asyncio::tokio::main(flavor = "current_thread")]
async fn main() -> PyResult<()> {
Ok(())
}
Multi-thread scheduler with custom worker thread count:
ⓘ
#[pyo3_asyncio::tokio::main(flavor = "multi_thread", worker_threads = 10)]
async fn main() -> PyResult<()> {
Ok(())
}