【发布时间】:2020-02-01 15:55:14
【问题描述】:
我使用的是 tokio 0.2.x,但我需要使用依赖于 hyper 0.12.35 的依赖项。
这会导致SpawnError { is_shutdown: true } 出现恐慌。
我设法以孤立的方式重现了这个:
cargo.toml
[dependencies]
tokio = { version = "0.2.11", features = ["full"] }
hyper = "0.12.35"
futures = "0.1.29"
这是代码:
use hyper::rt;
use futures::future as future01;
fn future_01() -> impl future01::Future<Item = (), Error = ()> {
future01::ok(())
}
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
rt::spawn(future_01());
Ok(())
}
我的依赖在实现中有这个rt::spawn,所以我不能修改它。
理想情况下,我想将rt::spawn 使用的默认执行程序设置为与tokio::main 提供的执行程序相同。这可能吗?
【问题讨论】:
标签: rust async-await rust-tokio hyper