Skip to content

panic_fuse does not terminate when one thread panics #1270

@scullionw

Description

@scullionw
use rayon::prelude::*;
use std::{thread, time::Duration};

fn run_workers(n: usize) {
    (0..n)
        .into_par_iter()
        .panic_fuse() // <- stop others ASAP if any worker panics
        .for_each(|i| {
            loop {
                println!("hi from thread: {i}");

                thread::sleep(Duration::from_secs(1));

                if i == 0 {
                    thread::sleep(Duration::from_secs(2));
                    panic!("oh no");
                }
            }
        });
}

fn main() {
    run_workers(10);

    println!("cya")
}

from the docs i would expect this to terminate?

(im trying to have a worker system where we let the system crash when there is a panic, like single threaded rust)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions