| Index: go/src/infra/monitoring/looper/looper.go
|
| diff --git a/go/src/infra/monitoring/looper/looper.go b/go/src/infra/monitoring/looper/looper.go
|
| index 9bbea5c94061a8a4c3385461da09b1b57b7b5893..2e3c3324961cf96bbb62c34c18ab706776812a68 100644
|
| --- a/go/src/infra/monitoring/looper/looper.go
|
| +++ b/go/src/infra/monitoring/looper/looper.go
|
| @@ -69,7 +69,9 @@ func Run(ctx context.Context, f Runner, cycle time.Duration, maxErrs int, c cloc
|
| }
|
|
|
| nextCycle = cycle - dur
|
| - tmr.Reset(nextCycle)
|
| + if tmr.Reset(nextCycle) {
|
| + log.Errorf("Timer was still active")
|
| + }
|
| }
|
|
|
| // Run f at least once.
|
| @@ -77,12 +79,15 @@ func Run(ctx context.Context, f Runner, cycle time.Duration, maxErrs int, c cloc
|
|
|
| // Keep running f until ctx is done.
|
| for {
|
| - if ar := <-tmr.GetC(); ar.Incomplete() {
|
| - return ret
|
| - }
|
| - run()
|
| - if !ret.Success {
|
| + select {
|
| + case <-ctx.Done():
|
| + tmr.Stop()
|
| return ret
|
| + case <-tmr.GetC():
|
| + run()
|
| + if !ret.Success {
|
| + return ret
|
| + }
|
| }
|
| }
|
| }
|
|
|