mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 13:10:06 +01:00
fix flaky test
This commit is contained in:
parent
3a1f458139
commit
087a96d22e
@ -47,6 +47,18 @@ impl SearchQueue {
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
// biased select because we wants to free up space before trying to register new tasks
|
||||
biased;
|
||||
_ = search_finished.recv() => {
|
||||
searches_running = searches_running.saturating_sub(1);
|
||||
if !queue.is_empty() {
|
||||
// Can't panic: the queue wasn't empty thus the range isn't empty.
|
||||
let remove = rng.gen_range(0..queue.len());
|
||||
let channel = queue.swap_remove(remove);
|
||||
let _ = channel.send(Permit { sender: sender.clone() });
|
||||
}
|
||||
},
|
||||
|
||||
search_request = receive_new_searches.recv() => {
|
||||
// this unwrap is safe because we're sure the `SearchQueue` still lives somewhere in actix-web
|
||||
let search_request = search_request.unwrap();
|
||||
@ -69,15 +81,6 @@ impl SearchQueue {
|
||||
}
|
||||
queue.push(search_request);
|
||||
},
|
||||
_ = search_finished.recv() => {
|
||||
searches_running = searches_running.saturating_sub(1);
|
||||
if !queue.is_empty() {
|
||||
// Can't panic: the queue wasn't empty thus the range isn't empty.
|
||||
let remove = rng.gen_range(0..queue.len());
|
||||
let channel = queue.swap_remove(remove);
|
||||
let _ = channel.send(Permit { sender: sender.clone() });
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user