make sure err is propagated

pull/1524/head^2
Darien Raymond 2018-08-05 17:56:49 +02:00
parent 8d7fab6aea
commit 8ed119e3f6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 12 additions and 9 deletions

View File

@ -88,8 +88,8 @@ func OnFailure(task Task) ExecutionOption {
} }
} }
func Single(task Task, opts ExecutionOption) Task { func Single(task Task, opts ...ExecutionOption) Task {
return Run(append([]ExecutionOption{Sequential(task)}, opts)...) return Run(append([]ExecutionOption{Sequential(task)}, opts...)...)
} }
func Run(opts ...ExecutionOption) Task { func Run(opts ...ExecutionOption) Task {
@ -120,14 +120,17 @@ func executeParallel(ctx context.Context, tasks []Task) error {
for _, task := range tasks { for _, task := range tasks {
<-s.Wait() <-s.Wait()
go func(f func() error) { go func(f Task) {
if err := f(); err != nil { err := f()
if err == nil {
s.Signal()
return
}
select { select {
case done <- err: case done <- err:
default: default:
} }
}
s.Signal()
}(task) }(task)
} }