aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-06-07 02:06:00 +0200
committerTeddy Wing2021-06-07 02:06:00 +0200
commitf98dad7a3a19c9f731fd87c8b3c0e14e976d76d6 (patch)
tree2af174e3a25ac66ebbc9978d2e9c00e3f49de2ff /src/main.rs
parentde2d6a2ddf747cc7d5d370b69e26e8355b00f1d4 (diff)
downloadreflectub-f98dad7a3a19c9f731fd87c8b3c0e14e976d76d6.tar.bz2
main: Collect errors from spawned tasks
Collect all errors into a list. I think I'm going to return them as a list from this function. The runtime appears a lot slower with this change. Need to figure out what that's about.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index a476ef0..0d4938d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,7 @@ use anyhow::{self, Context};
use chrono::DateTime;
use exitcode;
use filetime;
-use futures::{self, executor, future};
+// use futures::{self, executor, future};
use getopts::Options;
use parse_size::parse_size;
use sqlx;
@@ -137,16 +137,22 @@ fn run() -> anyhow::Result<()> {
}
// executor::block_on(future::join_all(joins));
- rt.block_on(async {
- let mut joins = tokio_stream::iter(&joins);
+ let results = rt.block_on(async {
+ let mut joins = tokio_stream::iter(&mut joins);
+ let mut results = Vec::new();
while let Some(task) = joins.next().await {
- let a = task.await?;
- dbg!(a);
+ let result = task.await;
+ results.push(result);
}
- Ok::<(), anyhow::Error>(())
- })?;
+ results
+ });
+
+ let errors = results.iter()
+ .filter(|r| r.is_err());
+
+ dbg!(&errors);
Ok(())
}