fix: Added a small timeout to the runNow() script scheduler
This is to avoid a small race conditions in the tests, where a script has signalled that it's finished loading but the schedular has not started waiting for the next task.
This commit is contained in:
parent
f65c5778a9
commit
20a9a8c758
|
@ -3,6 +3,7 @@ package scriptmanager
|
|||
import (
|
||||
"context"
|
||||
"github.com/pkg/errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type scriptScheduler struct {
|
||||
|
@ -41,7 +42,7 @@ func (ss *scriptScheduler) runNow(ctx context.Context, job func(ctx context.Cont
|
|||
select {
|
||||
case ss.jobChan <- scriptJob{ctx: ctx, job: job}:
|
||||
return nil
|
||||
default:
|
||||
case <-time.After(500 * time.Millisecond):
|
||||
return errors.New("a script is already running")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue