From f9c8fe5eaa4a012bf0e9aec6843c219fbc53f843 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 18 Oct 2022 17:50:52 +0200 Subject: [PATCH] Use a tokio block_in_place method for potentially blocking tasks --- meilisearch-http/src/routes/tasks.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/meilisearch-http/src/routes/tasks.rs b/meilisearch-http/src/routes/tasks.rs index 76e9707ab..e68c83465 100644 --- a/meilisearch-http/src/routes/tasks.rs +++ b/meilisearch-http/src/routes/tasks.rs @@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize}; use serde_cs::vec::CS; use serde_json::json; use time::{Duration, OffsetDateTime}; +use tokio::task::block_in_place; use crate::analytics::Analytics; use crate::extractors::authentication::{policies::*, GuardedData}; @@ -249,8 +250,7 @@ async fn cancel_tasks( tasks, }; - // TODO add a tokio_spawn - let task = index_scheduler.register(task_cancelation)?; + let task = block_in_place(|| index_scheduler.register(task_cancelation))?; let task_view = TaskView::from_task(&task); Ok(HttpResponse::Ok().json(task_view)) @@ -294,8 +294,7 @@ async fn delete_tasks( tasks, }; - // TODO add a tokio_spawn - let task = index_scheduler.register(task_deletion)?; + let task = block_in_place(|| index_scheduler.register(task_deletion))?; let task_view = TaskView::from_task(&task); Ok(HttpResponse::Ok().json(task_view))