debug, query_onlines_block_thread

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow
2023-11-16 10:15:51 +08:00
parent 5a51284550
commit 02bc5e3111
3 changed files with 40 additions and 30 deletions

View File

@@ -572,7 +572,6 @@ async fn direct_server(server: ServerPtr) {
}
}
#[tokio::main(flavor = "current_thread")]
pub async fn query_online_states<F: FnOnce(Vec<String>, Vec<String>)>(ids: Vec<String>, f: F) {
let test = false;
if test {
@@ -598,7 +597,11 @@ pub async fn query_online_states<F: FnOnce(Vec<String>, Vec<String>)>(ids: Vec<S
}
if query_begin.elapsed() > query_timeout {
log::debug!("query onlines timeout {:?} ({:?})", query_begin.elapsed(), query_timeout);
log::debug!(
"query onlines timeout {:?} ({:?})",
query_begin.elapsed(),
query_timeout
);
break;
}
@@ -679,8 +682,10 @@ async fn query_online_states_(
#[cfg(test)]
mod tests {
#[test]
fn test_query_onlines() {
use hbb_common::tokio;
#[tokio::test]
async fn test_query_onlines() {
super::query_online_states(
vec![
"152183996".to_owned(),
@@ -691,6 +696,7 @@ mod tests {
|onlines: Vec<String>, offlines: Vec<String>| {
println!("onlines: {:?}, offlines: {:?}", &onlines, &offlines);
},
);
)
.await;
}
}