Skip to content

Commit

Permalink
Panic when the API is not responding
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Jul 9, 2023
1 parent 434eca1 commit 39e7a79
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion typhon/api-client-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ async fn main() {
let jobset = handles::jobset((name.to_string(), jobset.to_string()));
s!(Res::JobsetEvaluate(evaluation) = Req::Jobset(jobset, requests::Jobset::Evaluate(true)));
let mut status = "pending".to_string();
let mut elapsed_time: u64 = 0;
while status == "pending" {
println!("Query evaluation's status...");
s!(Res::EvaluationInfo(responses::EvaluationInfo {
Expand All @@ -127,6 +128,15 @@ async fn main() {
}) = Req::Evaluation(evaluation.clone(), requests::Evaluation::Info));
status = new_status;
println!(" > status is '{}'", status.bold());
sleep(Duration::from_millis(200));
const WAIT_TIME_MS: u64 = 200;
const MAX_TIME_SEC: u64 = 60;
sleep(Duration::from_millis(WAIT_TIME_MS));
elapsed_time += WAIT_TIME_MS;
if elapsed_time > MAX_TIME_SEC * 1000 {
panic!(
"API is not responding: evaluation took more than {} seconds.",
MAX_TIME_SEC
);
}
}
}

0 comments on commit 39e7a79

Please sign in to comment.