Register the swap indexe task in a spawn blocking to be sure to never block the main thread

This commit is contained in:
Tamo 2023-09-07 11:37:02 +02:00
parent dc3d9c90d9
commit 66aa682e23

View File

@ -60,8 +60,7 @@ pub async fn swap_indexes(
}
let task = KindWithContent::IndexSwap { swaps };
let task = index_scheduler.register(task)?;
let task: SummarizedTaskView = task.into();
let task: SummarizedTaskView =
tokio::task::spawn_blocking(move || index_scheduler.register(task)).await??.into();
Ok(HttpResponse::Accepted().json(task))
}