自己在使用 #[tokio::test]
在 VSCode + rust-analyzer 时 总是出现
failed to write request: 管道正在被关闭。 (os error 232)rust-analyzermacro-error
测试代码是
#[tokio::test]
async fn time_out(){
use tokio::time::sleep;
// use futures::future::{self,AbortHandle,Abortable};
let a = || async{
sleep(Duration::from_secs(2)).await;
println!("{}","run a")
};
let _b = || { println!("{}","run b")};
// let (abort_handle,abort_registration) = AbortHandle::new_pair();
// let ca = Abortable::new(a,abort_registration);
// let cb = Abortable::new(b,abort_registration);
// let r = tokio::spawn(a);
// let re = future::join(r).await;
// let c = r.await.unwrap();
let c = a();
drop(c);
// c.await;
println!("{}","同步");
loop {
true;
}
}
依赖
[package]
name = "monitor"
version = "0.0.1"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.10.1", features = ["full"] }
# These dependencies are only used for the 'http_bench_*_ops' examples.
[dev-dependencies]
# tokio = { version = "1.10.1", features = ["full"] }
能解决吗?
1
共 1 条评论, 1 页
评论区
写评论请问你解决了吗?