mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
fix potential infinite loop
This commit is contained in:
parent
41707e3245
commit
d7b49fa671
@ -111,17 +111,19 @@ impl Server {
|
|||||||
|
|
||||||
|
|
||||||
pub async fn wait_update_id(&mut self, update_id: u64) {
|
pub async fn wait_update_id(&mut self, update_id: u64) {
|
||||||
loop {
|
// try 10 times to get status, or panic to not wait forever
|
||||||
|
for _ in 1..10 {
|
||||||
let (response, status_code) = self.get_update_status(update_id).await;
|
let (response, status_code) = self.get_update_status(update_id).await;
|
||||||
assert_eq!(status_code, 200);
|
assert_eq!(status_code, 200);
|
||||||
|
|
||||||
if response["status"] == "processed" || response["status"] == "error" {
|
if response["status"] == "processed" || response["status"] == "failed" {
|
||||||
eprintln!("{:#?}", response);
|
eprintln!("{:#?}", response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delay_for(Duration::from_secs(1)).await;
|
delay_for(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
|
panic!("Timeout waiting for update id");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global Http request GET/POST/DELETE async or sync
|
// Global Http request GET/POST/DELETE async or sync
|
||||||
|
Loading…
Reference in New Issue
Block a user