Move loop check to before sleep
@@ -81,7 +81,7 @@ version = 2
task.Kill(ctx, syscall.SIGKILL)
begin := time.Now()
deadline := begin.Add(interval).Add(epsilon)
- for time.Now().Before(deadline) {
+ for {
status, err := task.Status(ctx)
now := time.Now()
if err != nil {
@@ -97,6 +97,9 @@ version = 2
return
}
}
+ if time.Now().After(deadline) {
+ break
+ }
time.Sleep(epsilon)
}
t.Fatalf("%v: the task was not restarted in %s + %s",
