mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Use a tokio block_in_place method for potentially blocking tasks
This commit is contained in:
parent
c2ec4a089b
commit
f9c8fe5eaa
@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_cs::vec::CS;
|
use serde_cs::vec::CS;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use time::{Duration, OffsetDateTime};
|
use time::{Duration, OffsetDateTime};
|
||||||
|
use tokio::task::block_in_place;
|
||||||
|
|
||||||
use crate::analytics::Analytics;
|
use crate::analytics::Analytics;
|
||||||
use crate::extractors::authentication::{policies::*, GuardedData};
|
use crate::extractors::authentication::{policies::*, GuardedData};
|
||||||
@ -249,8 +250,7 @@ async fn cancel_tasks(
|
|||||||
tasks,
|
tasks,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO add a tokio_spawn
|
let task = block_in_place(|| index_scheduler.register(task_cancelation))?;
|
||||||
let task = index_scheduler.register(task_cancelation)?;
|
|
||||||
let task_view = TaskView::from_task(&task);
|
let task_view = TaskView::from_task(&task);
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json(task_view))
|
Ok(HttpResponse::Ok().json(task_view))
|
||||||
@ -294,8 +294,7 @@ async fn delete_tasks(
|
|||||||
tasks,
|
tasks,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO add a tokio_spawn
|
let task = block_in_place(|| index_scheduler.register(task_deletion))?;
|
||||||
let task = index_scheduler.register(task_deletion)?;
|
|
||||||
let task_view = TaskView::from_task(&task);
|
let task_view = TaskView::from_task(&task);
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json(task_view))
|
Ok(HttpResponse::Ok().json(task_view))
|
||||||
|
Loading…
Reference in New Issue
Block a user