interruptible_wait: evaluate Predicate immediately

Previous behaviour was to wait PredicateInterval before the first
time that the Predicate is evaluated
This commit is contained in:
Cheng Sun 2014-12-09 14:50:44 +00:00
parent 94dcf160df
commit 651274e508

View File

@ -35,13 +35,14 @@ func (wait InterruptibleWait) Wait(state multistep.StateBag) error {
go func() { go func() {
for { for {
if complete, err := wait.Predicate(); err != nil || complete {
predicateResult <- PredicateResult{complete, err}
return
}
select { select {
case <-time.After(wait.PredicateInterval): case <-time.After(wait.PredicateInterval):
if complete, err := wait.Predicate(); err != nil || complete { // do nothing; loop again
predicateResult <- PredicateResult{complete, err}
return
}
case <-stopWaiting: case <-stopWaiting:
return return
} }