Browse Source
Otherwise, any errors occurring within these tasks are silently ignored.refactor/no-log-handler
Thomas Eizinger
3 years ago
4 changed files with 18 additions and 1 deletions
@ -0,0 +1,14 @@ |
|||
use std::fmt; |
|||
use std::future::Future; |
|||
|
|||
pub fn spawn_fallible<F, E>(future: F) |
|||
where |
|||
F: Future<Output = Result<(), E>> + Send + 'static, |
|||
E: fmt::Display, |
|||
{ |
|||
tokio::spawn(async move { |
|||
if let Err(e) = future.await { |
|||
tracing::warn!("Task failed: {:#}", e); |
|||
} |
|||
}); |
|||
} |
Loading…
Reference in new issue