From 6e23040464a1db90e757b36d52a13711efc2cdc2 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 23 Jan 2024 16:53:05 +0100 Subject: [PATCH] Use with tokio channel in Meilisearch --- meilisearch/src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/meilisearch/src/main.rs b/meilisearch/src/main.rs index 373280e58..75308258e 100644 --- a/meilisearch/src/main.rs +++ b/meilisearch/src/main.rs @@ -57,13 +57,13 @@ fn setup(opt: &Opt) -> anyhow::Result<()> { ), ); - std::thread::spawn(move || { + tokio::task::spawn(async move { loop { - trace.flush().unwrap(); - match trace.receive() { - Ok(ControlFlow::Continue(_)) => continue, - Ok(ControlFlow::Break(_)) => break, - Err(_) => todo!(), + match tokio::time::timeout(std::time::Duration::from_secs(1), trace.receive()).await { + Ok(Ok(ControlFlow::Continue(()))) => continue, + Ok(Ok(ControlFlow::Break(_))) => break, + Ok(Err(_)) => todo!(), + Err(_) => trace.flush().unwrap(), } } while trace.try_receive().is_ok() {}