From f1482c00761000bd430db16085303aed3d0bca8e Mon Sep 17 00:00:00 2001 From: Kasisnu <5044120+kasisnu@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:25:41 +0530 Subject: [PATCH] Zzzzzzzs --- .../db_health_checker_thread.rs | 6 ++---- .../src/threads/poll_ip_banlist_thread.rs | 6 +++--- .../src/threads/poll_model_token_info_thread.rs | 10 +++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/service/web/storyteller_web/src/threads/db_health_checker_thread/db_health_checker_thread.rs b/crates/service/web/storyteller_web/src/threads/db_health_checker_thread/db_health_checker_thread.rs index 0c483ea6c4..ce2c7e8bb5 100644 --- a/crates/service/web/storyteller_web/src/threads/db_health_checker_thread/db_health_checker_thread.rs +++ b/crates/service/web/storyteller_web/src/threads/db_health_checker_thread/db_health_checker_thread.rs @@ -1,12 +1,10 @@ -use std::thread; use std::time::Duration; use log::debug; use log::error; use log::warn; -use sqlx::MySqlPool; - use mysql_queries::queries::health_check::health_check_query::health_check_db; +use sqlx::MySqlPool; use crate::threads::db_health_checker_thread::db_health_check_status::HealthCheckStatus; @@ -34,7 +32,7 @@ pub async fn db_health_checker_thread( } } - thread::sleep(check_duration); + tokio::time::sleep(check_duration).await; } warn!("Should never happen: Health Checker Exits"); diff --git a/crates/service/web/storyteller_web/src/threads/poll_ip_banlist_thread.rs b/crates/service/web/storyteller_web/src/threads/poll_ip_banlist_thread.rs index dd94e92530..ea3c18ccab 100644 --- a/crates/service/web/storyteller_web/src/threads/poll_ip_banlist_thread.rs +++ b/crates/service/web/storyteller_web/src/threads/poll_ip_banlist_thread.rs @@ -2,8 +2,8 @@ use std::collections::HashSet; use std::thread; use std::time::Duration; -use log::{debug, error, info}; use log::warn; +use log::{debug, error, info}; use sqlx::MySqlPool; use actix_helpers::middleware::banned_ip_filter::ip_ban_list::ip_ban_list::IpBanList; @@ -23,7 +23,7 @@ pub async fn poll_ip_bans( Ok(bans) => bans, Err(e) => { error!("Error polling IP bans: {:?}", e); - thread::sleep(Duration::from_millis(30_000)); + tokio::time::sleep(Duration::from_millis(30_000)).await; continue; } }; @@ -49,6 +49,6 @@ pub async fn poll_ip_bans( }, } - thread::sleep(Duration::from_millis(20_000)); + tokio::time::sleep(Duration::from_millis(20_000)).await; } } diff --git a/crates/service/web/storyteller_web/src/threads/poll_model_token_info_thread.rs b/crates/service/web/storyteller_web/src/threads/poll_model_token_info_thread.rs index 27d9d78067..2ccb947862 100644 --- a/crates/service/web/storyteller_web/src/threads/poll_model_token_info_thread.rs +++ b/crates/service/web/storyteller_web/src/threads/poll_model_token_info_thread.rs @@ -29,14 +29,14 @@ pub async fn poll_model_token_info_thread( let interval_wait = easyenv::get_env_duration_seconds_or_default( "POLL_MODEL_TOKEN_INTERVAL_SECS", Duration::from_secs(10 * 60)); - std::thread::sleep(startup_wait); + tokio::time::sleep(startup_wait).await; loop { let token_info_items = match query_voice_conversion_models(&mysql_pool).await { Ok(infos) => infos, Err(err) => { error!("Error polling voice conversion model token info: {:?}", err); - std::thread::sleep(error_wait); + tokio::time::sleep(error_wait).await; continue; } }; @@ -49,13 +49,13 @@ pub async fn poll_model_token_info_thread( error!("Error inserting model token info: {:?}", err); } - std::thread::sleep(between_wait); + tokio::time::sleep(between_wait).await; let token_info_items = match query_model_weight_models(&mysql_pool).await { Ok(infos) => infos, Err(err) => { error!("Error polling model weight token info: {:?}", err); - std::thread::sleep(error_wait); + tokio::time::sleep(error_wait).await; continue; } }; @@ -68,7 +68,7 @@ pub async fn poll_model_token_info_thread( error!("Error inserting model token info: {:?}", err); } - std::thread::sleep(interval_wait); + tokio::time::sleep(interval_wait).await; } }