fix(repo): avoid blocking threads when pausing
Some checks failed
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
Rust / build (push) Failing after 7m1s

This commit is contained in:
Paul Campbell 2024-08-30 20:58:38 +01:00
parent a650996ecd
commit a87241c3d1
2 changed files with 10 additions and 4 deletions

View file

@ -53,7 +53,7 @@ impl Handler<AdvanceNext> for RepoActor {
let sleep_duration = self.sleep_duration; let sleep_duration = self.sleep_duration;
let log = self.log.clone(); let log = self.log.clone();
async move { async move {
std::thread::sleep(sleep_duration); actix_rt::time::sleep(sleep_duration).await;
do_send(&addr, ValidateRepo::new(message_token), log.as_ref()); do_send(&addr, ValidateRepo::new(message_token), log.as_ref());
} }
.in_current_span() .in_current_span()

View file

@ -2,7 +2,7 @@
use actix::prelude::*; use actix::prelude::*;
use git_next_core::git::{forge::commit::Status, graph, UserNotification}; use git_next_core::git::{forge::commit::Status, graph, UserNotification};
use tracing::{debug, Instrument as _}; use tracing::{debug, Instrument};
use crate::{ use crate::{
repo::{ repo::{
@ -37,8 +37,14 @@ impl Handler<ReceiveCIStatus> for RepoActor {
do_send(&addr, AdvanceMain::new(next), self.log.as_ref()); do_send(&addr, AdvanceMain::new(next), self.log.as_ref());
} }
Status::Pending => { Status::Pending => {
std::thread::sleep(sleep_duration); let log = self.log.clone();
do_send(&addr, ValidateRepo::new(message_token), self.log.as_ref()); async move {
actix_rt::time::sleep(sleep_duration).await;
do_send(&addr, ValidateRepo::new(message_token), log.as_ref());
}
.in_current_span()
.into_actor(self)
.wait(ctx);
} }
Status::Fail => { Status::Fail => {
tracing::warn!("Checks have failed"); tracing::warn!("Checks have failed");