Skip to content

Commit

Permalink
Fix some lifetime issues in main maple thread, still having errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Mar 27, 2024
1 parent 303c9af commit df4fcbf
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/maple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,39 +295,36 @@ async fn run_ingest() -> Result<(), Box<dyn Error>> {
attempt_ids
};

rt.spawn({
let arc_conn_pool = Arc::clone(&arc_conn_pool);
let download_feed_info_hashmap = Arc::clone(&download_feed_info_hashmap);
async move {
for (feed_id, _) in unzip_feeds
.iter()
.filter(|unzipped_feed| unzipped_feed.1 == true)
{}
}
});
let attempt_ids = Arc::new(attempt_ids);

for (feed_id, _) in unzip_feeds
.iter()
.filter(|unzipped_feed| unzipped_feed.1 == true)
{
rt.spawn({

let attempt_ids = Arc::clone(&attempt_ids);
let attempt_id = attempt_ids.get(feed_id).unwrap().clone();
if let Some(chateau_id) = feed_id_to_chateau_lookup.get(feed_id) {
let chateau_id = chateau_id.clone();

rt.spawn(
{
let arc_conn_pool = Arc::clone(&arc_conn_pool);
let download_feed_info_hashmap = Arc::clone(&download_feed_info_hashmap);
async move {
let conn_pool = arc_conn_pool.as_ref();
let conn_pre = conn_pool.get().await;
let conn = &mut conn_pre.unwrap();
let attempt_id = attempt_ids.get(feed_id).unwrap();

let this_download_data = download_feed_info_hashmap.get(feed_id).unwrap();

if let Some(chateau_id) = feed_id_to_chateau_lookup.get(feed_id) {

// call function to process GTFS feed, accepting feed_id, diesel pool args, chateau_id, attempt_id
let gtfs_process_result = gtfs_process_feed(
&feed_id,
Arc::clone(&arc_conn_pool),
chateau_id,
attempt_id,
&chateau_id,
&attempt_id,
&this_download_data,
)
.await;
Expand Down Expand Up @@ -360,10 +357,11 @@ async fn run_ingest() -> Result<(), Box<dyn Error>> {

//Delete objects from the attempt
}
}

}
});
}
}
}
} else {
eprintln!("Not enough data in transitland!");
Expand Down

0 comments on commit df4fcbf

Please sign in to comment.