mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-11-14 04:01:25 +00:00
Fix in rpc_client (see comment in code)
This commit is contained in:
parent
897fafa8db
commit
73574ab43e
1 changed files with 11 additions and 1 deletions
|
@ -117,10 +117,20 @@ impl<M: RpcMessage + 'static> RpcClient<M> {
|
|||
if results.len() >= stop_after {
|
||||
// Continue requests in background
|
||||
// TODO: make this optionnal (only usefull for write requests)
|
||||
self.clone().background.spawn_cancellable(async move {
|
||||
|
||||
// Continue the remaining requests immediately using tokio::spawn
|
||||
// but enqueue a task in the background runner
|
||||
// to ensure that the process won't exit until the requests are done
|
||||
// (if we had just enqueued the resp_stream.collect directly in the background runner,
|
||||
// the requests might have been put on hold in the background runner's queue,
|
||||
// in which case they might timeout or otherwise fail)
|
||||
let wait_finished_fut = tokio::spawn(async move {
|
||||
resp_stream.collect::<Vec<_>>().await;
|
||||
Ok(())
|
||||
});
|
||||
self.clone().background.spawn(wait_finished_fut.map(|x| {
|
||||
x.unwrap_or_else(|e| Err(Error::Message(format!("Await failed: {}", e))))
|
||||
}));
|
||||
|
||||
Ok(results)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue