From 6fee7561dec7e6eef5139d103f09eabf93e04210 Mon Sep 17 00:00:00 2001 From: jordao Date: Thu, 10 Aug 2023 16:59:59 +0200 Subject: [PATCH] Took last possible point of livelock --- rust-orchestration/src/lib.rs | 67 ++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/rust-orchestration/src/lib.rs b/rust-orchestration/src/lib.rs index a59eee38..ea587f5b 100644 --- a/rust-orchestration/src/lib.rs +++ b/rust-orchestration/src/lib.rs @@ -1118,28 +1118,53 @@ impl IdentificationModule for ExternalServerIdentificationModule { self.write_line_to_input(format!("SOLVED INLINE {}", message.to_json_str()).as_str()); } self.write_line_to_input("INTEGRATE"); - return std::iter::repeat_with(|| self.read_line_from_output()) - .flatten() - .map(|line| { - if line.contains("DESIGN") { - let payload = &line[6..].trim(); - let h = DesignModelHeader::from_file(std::path::Path::new(payload)); - if let Some(header) = h { - let boxed = Box::new(header) as Box; - return Some(boxed); + self.map_output(|buf| { + buf.lines() + .flatten() + .map(|line| { + if line.contains("DESIGN") { + let payload = &line[6..].trim(); + let h = DesignModelHeader::from_file(std::path::Path::new(payload)); + if let Some(header) = h { + let boxed = Box::new(header) as Box; + return Some(boxed); + } + } else if !line.trim().eq_ignore_ascii_case("FINISHED") { + warn!( + "Ignoring non-compliant integration result by module {}: {}", + self.unique_identifier(), + line + ); } - } else if !line.trim().eq_ignore_ascii_case("FINISHED") { - warn!( - "Ignoring non-compliant integration result by module {}: {}", - self.unique_identifier(), - line - ); - } - None - }) - .take_while(|x| x.is_some()) - .flatten() - .collect(); + None + }) + .take_while(|x| x.is_some()) + .flatten() + .collect() + }) + .unwrap_or(Vec::new()) + // return std::iter::repeat_with(|| self.read_line_from_output()) + // .flatten() + // .map(|line| { + // if line.contains("DESIGN") { + // let payload = &line[6..].trim(); + // let h = DesignModelHeader::from_file(std::path::Path::new(payload)); + // if let Some(header) = h { + // let boxed = Box::new(header) as Box; + // return Some(boxed); + // } + // } else if !line.trim().eq_ignore_ascii_case("FINISHED") { + // warn!( + // "Ignoring non-compliant integration result by module {}: {}", + // self.unique_identifier(), + // line + // ); + // } + // None + // }) + // .take_while(|x| x.is_some()) + // .flatten() + // .collect(); // if let Some(integrated_line) = self.read_line_from_output() { // let num_models = integrated_line[10..].trim().parse().ok().unwrap_or(0usize); // for _ in 0..num_models {