fix(tvix/store/bin): use spawn_blocking to call import_path
This operation is blocking, so it should be run inside a blocking tokio task. Tokio panics if it detects a blocking operation inside a non- blocking task, so cl/8619 would cause it to panic (as the GRPC clients use spawn_blocking under the hood). As spawn_blocking moves, and we can't clone `TvixStoreIO` (see cl/8614), we create a new instance of TvixStoreIO inside each loop iteration. Change-Id: I0c6548b3d4ac42d180d4c92314af8fd2b16510da Reviewed-on: https://cl.tvl.fyi/c/depot/+/8618 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
24cbf93729
commit
92b6d15da3
1 changed files with 14 additions and 10 deletions
|
@ -128,17 +128,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
directory_service.clone(),
|
||||
);
|
||||
|
||||
let mut io = TvixStoreIO::new(
|
||||
blob_service,
|
||||
directory_service,
|
||||
path_info_service,
|
||||
nar_calculation_service,
|
||||
);
|
||||
|
||||
for path in paths {
|
||||
let path_info = io
|
||||
.import_path_with_pathinfo(&path)
|
||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
|
||||
let path_move = path.clone();
|
||||
|
||||
let mut io = TvixStoreIO::new(
|
||||
blob_service.clone(),
|
||||
directory_service.clone(),
|
||||
path_info_service.clone(),
|
||||
nar_calculation_service.clone(),
|
||||
);
|
||||
|
||||
let path_info = tokio::task::spawn_blocking(move || {
|
||||
io.import_path_with_pathinfo(&path_move)
|
||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))
|
||||
})
|
||||
.await??;
|
||||
|
||||
match path_info.node.unwrap().node.unwrap() {
|
||||
tvix_store::proto::node::Node::Directory(directory_node) => {
|
||||
|
|
Loading…
Reference in a new issue