pub use v_module_queue::{
get_cmd, get_inner_binobj_as_individual, get_info_of_module, init_log,
init_log_with_filter, init_log_with_params, Module, PrepareError,
};
use crate::module::info::ModuleInfo;
use std::{thread, time};
pub fn wait_load_ontology() -> i64 {
wait_module("input-onto", 1)
}
pub fn wait_module(module_name: &str, wait_op_id: i64) -> i64 {
if wait_op_id < 0 {
error!(
"wait module [{}] to complete op_id={}",
module_name, wait_op_id
);
return -1;
}
info!(
"wait module [{}] to complete op_id={}",
module_name, wait_op_id
);
loop {
let module_info = ModuleInfo::new("./data", module_name, false);
if module_info.is_err() {
error!(
"fail open info of [{}], err={:?}",
module_name,
module_info.err()
);
thread::sleep(time::Duration::from_millis(300));
continue;
}
let mut info = module_info.unwrap();
loop {
if let Some((_, committed)) = info.read_info() {
if committed >= wait_op_id {
info!(
"wait module [{}] to complete op_id={}, found commited_op_id={}",
module_name, wait_op_id, committed
);
return committed;
}
} else {
error!("fail read info for module [{}]", module_name);
}
thread::sleep(time::Duration::from_millis(300));
}
}
}