From f87ae23301caf5d205349bd7b66f953bcdc47eba Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:31:12 -0800 Subject: [PATCH] handle exits properly --- Cargo.toml | 8 ++++---- src/aspen/main.rs | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c240465..d6039b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,10 +51,10 @@ rand = "0.8.5" titlecase = "3.2" rayon = "1.8.0" chrono = "0.4.31" -geo-types = "0.7.13" +geo-types = "0.7.14" geo-postgis = "0.2.2" -geo = "0.28.0" -tarpc = {version = "0.34.0", features = ["full"]} +geo = "0.29.0" +tarpc = {version = "0.35.0", features = ["full"]} anyhow = "1.0.75" tracing = "0.1.40" tokio-serde = "0.9" @@ -72,7 +72,7 @@ dmfr = "0.1.0" chateau = {git = "https://github.com/catenarytransit/chateau"} dmfr-dataset-reader = "0.2.0" uuid = {version = "1.8.0", features = ["v4", "fast-rng", "macro-diagnostics"]} -zip = "2.2.0" +zip = "2.2.1" git2 = "0.19" zip-extract = "0.2.1" serde_derive = "1.0.197" diff --git a/src/aspen/main.rs b/src/aspen/main.rs index 3184f8a..a355ba9 100644 --- a/src/aspen/main.rs +++ b/src/aspen/main.rs @@ -837,13 +837,23 @@ async fn main() -> anyhow::Result<()> { } }()); - let result_series = tokio::try_join!( - leader_thread_handler, - async_from_alpenrose_processor_handler, - tarpc_server, - etcd_lease_renewer - ); + async fn flatten(handle: tokio::task::JoinHandle>>) -> Result> { + match handle.await { + Ok(Ok(result)) => Ok(result), + Ok(Err(err)) => Err(err), + Err(err) => Err(Box::new(err)), + } + } + let result_series = tokio::try_join!( + flatten(leader_thread_handler), + flatten(async_from_alpenrose_processor_handler), + flatten(tarpc_server), + flatten(etcd_lease_renewer) + ).unwrap(); + + Ok(()) +/* match result_series { Ok(result_series_ok) => { println!("All threads have exited"); @@ -883,7 +893,7 @@ async fn main() -> anyhow::Result<()> { panic!("{:#?}", e); Err(anyhow::Error::new(e)) } - } + }*/ } enum SaveTimestamp {