#hyperlane #time #format #day #language

recoverable-spawn

A thread that supports automatic recovery from panics, allowing threads to restart after a panic. Useful for resilient and fault-tolerant concurrency in network and web programming.

58 releases (stable)

Uses new Rust 2024

3.9.9 Dec 13, 2025
3.9.7 Oct 19, 2025
3.9.1 Jul 30, 2025
3.5.4 Mar 30, 2025
0.8.0 Jan 10, 2025

#1097 in Network programming

24 downloads per month
Used in 4 crates (2 directly)

MIT license

20KB
275 lines

recoverable-spawn

Official Documentation

Api Docs

A thread that supports automatic recovery from panics, allowing threads to restart after a panic. Useful for resilient and fault-tolerant concurrency in network and web programming.

Installation

To use this crate, you can run cmd:

cargo add recoverable-spawn

Use

recoverable_spawn

use recoverable_spawn::*;

let msg: &str = "test";
let res: SyncSpawnResult = recoverable_spawn(move || {
    panic!("{}", msg);
});
let res: SyncSpawnResult = recoverable_spawn_with_error_handle(
    move || {
        panic!("{}", msg);
    },
    |err| {
        println!("handle error => {}", err);
    },
);

recoverable_spawn_with_error_handle

use recoverable_spawn::*;

let msg: &str = "test";
let res: SyncSpawnResult = recoverable_spawn_with_error_handle(
    move || {
        panic!("{}", msg);
    },
    |err| {
        println!("handle error => {}", err);
    },
);

async_recoverable_spawn

use recoverable_spawn::*;

let msg: &str = "test";
let res: AsyncSpawnResult = async_recoverable_spawn(move || async move {
    panic!("{}", msg);
});

async_recoverable_spawn_catch

use recoverable_spawn::*;

let msg: &str = "test";
let res: AsyncSpawnResult = async_recoverable_spawn_catch(
    move || async move {
        panic!("{}", msg);
    },
    move |err| async move {
        println!("handle error => {}", err);
    },
);

async_recoverable_spawn_catch_finally

use recoverable_spawn::*;

let msg: &str = "test";
let res: AsyncSpawnResult = async_recoverable_spawn_catch_finally(
    move || async move {
        panic!("{}", msg);
    },
    move |err| async move {
        println!("handle error => {}", err);
        panic!("{}", err);
    },
    move || async move {
        println!("finally");
    },
);

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Contact

For any inquiries, please reach out to the author at root@ltpp.vip.

Dependencies

~4MB
~57K SLoC