Use newly &self Supervisor.wait to drop wait loop
-use std::{sync::Arc, time::Duration};
+use std::sync::Arc;
-use tokio::{sync::RwLock, time::timeout};
+use tokio::sync::RwLock;
use crate::{command::Supervisor, error::RuntimeError, signal::process::SubSignal};
@@ -43,17 +43,9 @@ impl ProcessHolder {
}
pub async fn wait(&self) -> Result<(), RuntimeError> {
- // Loop to allow concurrent operations while waiting
- loop {
- if let Some(p) = self.0.write().await.as_mut() {
- match timeout(Duration::from_millis(20), p.wait()).await {
- Err(_timeout) => continue,
- Ok(Err(err)) => break Err(err),
- Ok(Ok(())) => break Ok(()),
- }
- } else {
- break Ok(());
- }
+ if let Some(p) = self.0.read().await.as_ref() {
+ p.wait().await?;
}
+ Ok(())
}
}
