mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
Fix double-actioning in throttle
This commit is contained in:
parent
b42336cb74
commit
9b94f18890
1 changed files with 10 additions and 0 deletions
|
@ -177,6 +177,12 @@ pub async fn worker(
|
|||
Ok(None) => break,
|
||||
Ok(Some(event)) => {
|
||||
trace!(?event, "got event");
|
||||
|
||||
if set.is_empty() {
|
||||
trace!("event is the first, resetting throttle window");
|
||||
last = Instant::now();
|
||||
}
|
||||
|
||||
set.push(event);
|
||||
|
||||
let elapsed = last.elapsed();
|
||||
|
@ -247,6 +253,7 @@ async fn apply_outcome(
|
|||
(Some(p), Outcome::Stop) => {
|
||||
p.kill().await?;
|
||||
p.wait().await?;
|
||||
*process = None;
|
||||
}
|
||||
(p @ None, o @ Outcome::Stop)
|
||||
| (p @ Some(_), o @ Outcome::Start)
|
||||
|
@ -261,6 +268,7 @@ async fn apply_outcome(
|
|||
|
||||
// TODO: pre-spawn hook
|
||||
|
||||
debug!(grouped=%working.grouped, ?command, "spawning command");
|
||||
let proc = if working.grouped {
|
||||
Process::Grouped(command.group_spawn()?)
|
||||
} else {
|
||||
|
@ -270,6 +278,8 @@ async fn apply_outcome(
|
|||
// TODO: post-spawn hook
|
||||
|
||||
*process = Some(proc);
|
||||
|
||||
// TODO: post-stop hook (immediately after *process* ends, not when Stop is applied)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue