Print all running tasks periodically

This commit is contained in:
Igor Katson 2023-12-01 10:48:16 +00:00
parent d1ad2c7d51
commit 414b2c5f65
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5

View file

@ -6,12 +6,25 @@ pub fn spawn(
) -> tokio::task::JoinHandle<()> { ) -> tokio::task::JoinHandle<()> {
let fut = async move { let fut = async move {
trace!("started"); trace!("started");
match fut.await { tokio::pin!(fut);
Ok(_) => { let mut trace_interval = tokio::time::interval(std::time::Duration::from_secs(5));
trace!("finished");
} loop {
Err(e) => { tokio::select! {
error!("finished with error: {:#}", e) _ = trace_interval.tick() => {
trace!("still running");
},
r = &mut fut => {
match r {
Ok(_) => {
trace!("finished");
}
Err(e) => {
error!("finished with error: {:#}", e)
}
}
return;
}
} }
} }
} }