-
The code below should panic the 'main' thread. But eventually, the process print backtrace and then exit with code 0. But it is expected to exit with a non-zero code. use std::time::Duration;
fn main(){
let basic_rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build().unwrap();
let local = tokio::task::LocalSet::new();
local.block_on(&basic_rt, async {
local.spawn_local(async {
panic!("failed");
});
});
local.block_on(&basic_rt, async {
tokio::time::sleep(Duration::from_secs(1)).await;
});
} More specifically, I am writing unit tests. Some code panic in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You will need to Unfortunately, there's no way to change how the runtime handles panics. |
Beta Was this translation helpful? Give feedback.
You will need to
.await
(orblock_on
) theJoinHandle
that it returns and check its return value for errors.Unfortunately, there's no way to change how the runtime handles panics.