You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, a panic!() within spawned tasks kills the runtime thread because we are not catching it. Tokio, by default, catches all the panics from the spawned task, and a configuration entry is provided to turn this off.
Perhaps Monoio could also catch panics and allow users to enable or disable this behavior through a configuration entry.
Describe the solution you'd like
The following code snippet implements a spawn() that catches the panic and forwards it to JoinHandle:
use futures::{FutureExt,TryFutureExt};use monoio::task::JoinHandle;use std::{any::Any, future::Future};fnspawn_with_panic_caught<F>(future:F,) -> JoinHandle<Result<F::Output,Box<dynAny + 'static>>>whereF:Future + 'static,F::Output:'static,{let future = std::panic::AssertUnwindSafe(future).catch_unwind().map_err(|e| e asBox<dynAny + 'static>);
monoio::spawn(future)}
Describe alternatives you've considered
None
Additional context
None
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Currently, a
panic!()
within spawned tasks kills the runtime thread because we are not catching it. Tokio, by default, catches all the panics from the spawned task, and a configuration entry is provided to turn this off.Perhaps Monoio could also catch panics and allow users to enable or disable this behavior through a configuration entry.
Describe the solution you'd like
The following code snippet implements a
spawn()
that catches the panic and forwards it toJoinHandle
:Describe alternatives you've considered
None
Additional context
None
The text was updated successfully, but these errors were encountered: