From 01802737b170a4258a8f43a002fa2ee579b1c166 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Thu, 21 Mar 2024 00:50:18 -0700 Subject: [PATCH] Make pool reference arc --- src/maple/gtfs_process.rs | 2 +- src/maple/main.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/maple/gtfs_process.rs b/src/maple/gtfs_process.rs index 9b81205e..3f766610 100644 --- a/src/maple/gtfs_process.rs +++ b/src/maple/gtfs_process.rs @@ -5,7 +5,7 @@ use std::error::Error; // Removal of the attribution is not allowed, as covered under the AGPL license // take a feed id and throw it into postgres -pub async fn gtfs_process_feed(feed_id: &str, pool: Arc>) -> Result<(), Box> { +pub async fn gtfs_process_feed(feed_id: &str, pool: &Arc>) -> Result<(), Box> { let path = format!("gtfs_uncompressed/{}", feed_id); let gtfs = gtfs_structures::Gtfs::new(path.as_str())?; diff --git a/src/maple/main.rs b/src/maple/main.rs index 1b731194..ae3839ab 100644 --- a/src/maple/main.rs +++ b/src/maple/main.rs @@ -241,10 +241,14 @@ async fn run_ingest() -> Result<(), Box> { let pool = Arc::new(pool); - rt.spawn(async move { + rt.spawn( + { + let pool = Arc::clone(&pool); + async move { for (feed_id, _) in unzip_feeds.iter().filter(|unzipped_feed| unzipped_feed.1 == true) { - gtfs_process_feed(&feed_id, pool); + let gtfs_process_result = gtfs_process_feed(&feed_id, &pool).await; } + } }); }