interruptible_wait: check for interruption immediately
Akin to 651274e508
This commit is contained in:
parent
03e3a7ad85
commit
c392b5499e
@ -51,7 +51,7 @@ func (wait InterruptibleWait) Wait(state multistep.StateBag) error {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(wait.PredicateInterval):
|
case <-time.After(wait.PredicateInterval):
|
||||||
// do nothing; loop again
|
continue
|
||||||
case <-stopWaiting:
|
case <-stopWaiting:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -63,14 +63,17 @@ func (wait InterruptibleWait) Wait(state multistep.StateBag) error {
|
|||||||
for {
|
for {
|
||||||
// wait for either install to complete/error,
|
// wait for either install to complete/error,
|
||||||
// an interrupt to come through, or a timeout to occur
|
// an interrupt to come through, or a timeout to occur
|
||||||
|
|
||||||
|
if _, ok := state.GetOk(multistep.StateCancelled); ok {
|
||||||
|
return InterruptedError{}
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case result := <-predicateResult:
|
case result := <-predicateResult:
|
||||||
return result.err
|
return result.err
|
||||||
|
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
if _, ok := state.GetOk(multistep.StateCancelled); ok {
|
continue
|
||||||
return InterruptedError{}
|
|
||||||
}
|
|
||||||
|
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
if wait.Predicate != nil {
|
if wait.Predicate != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user