async fn main_loop() -> Result<()> {
tokio::select! {
result = tokio::time::timeout(Duration::from_secs(5), async_cpp_wrapper_fn()) => {
match result {
Ok(r) => r,
Err(_) => Err("timeout")
}
},
close_signal => { Ok("shutdown") }
}
}
async fn async_cpp_wrapper_fn() -> { ... }
I wrapped a cpp logic into an async task, then timeout
on it in my application(the main_loop
will be spawn onto a reserved thread, but the log print indicated the flow stuck in the wrapper function more than 5s sometimes(up to hours), hard to reproduce. Is there any possible direction to find the cause? Maybe the thread was blocked by cpp?