-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQUEST] Allow panics in places like MainContext::spawn_local
to propogate up to the caller
#1229
Comments
You want those panics to propagate up to e.g. |
I'm pretty sure just from Specifically I'm wanting this code to crash completely in the first execution of the loop, instead of managing to go through all five runs: use glib::MainContext;
fn main() {
let ctx = MainContext::new();
ctx.spawn(async {
panic!("OH NO!");
});
for i in 0..5 {
println!("DID WORK #{i}: {}", ctx.iteration(false));
}
} |
We can't really have the panics propagate up like this as the The problem here is the |
I'd be fine with aborting as well, the way things are being handled in Relm4/Relm4#578 is just causing my application to not die out (as the panics aren't processed from the
I understand that, but it's still something I think could be really useful in certain situations (like mine). I can't really think of another way of doing this all in a clean manner, and having this kind of functionality in |
Actually that should be possible. We could spawn an async task that receives all join handles and waits for them to complete. When a panic happens, we could execute some code from there. IMO there is nothing that needs to be changed in gtk-rs. As it was pointed out, basically all async runtimes catch unwinds and with the C-code in between, it is not feasible to change that anyway. Maybe adding an option for panic=abort would be useful though. |
Looking at this again, since the only option is to abort this is pretty easily solvable in my program by just adding |
Currently
MainContext::spawn_local
won't propagate panics up to the caller if those future's aren't awaited and.unwrap()
ed. I have a use case where I'd like to get panics in those locations up to the root of my application though (see Relm4/Relm4#578), and I haven't found any current way to implement that with whatglib
provides.I've looked around loosely at the places
catch_unwind
is used throughout this codebase, but I was mostly left clueless on how I might change the functionality to propagate panics up. How hard would this functionality be to add?The text was updated successfully, but these errors were encountered: