mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
make sure workers are done when closing via a WaitGroup
still running out of goroutines in race tests in CI, so hopefully this fixes that.
This commit is contained in:
parent
7d7a5539ca
commit
a7d9b0a5ae
1 changed files with 9 additions and 2 deletions
11
executor.go
11
executor.go
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pilosa/pilosa/pql"
|
||||
|
|
@ -57,7 +58,8 @@ type executor struct {
|
|||
// Stores key/id translation data.
|
||||
TranslateStore TranslateStore
|
||||
|
||||
work chan job
|
||||
workersWG sync.WaitGroup
|
||||
work chan job
|
||||
}
|
||||
|
||||
// executorOption is a functional option type for pilosa.Executor
|
||||
|
|
@ -88,13 +90,18 @@ func newExecutor(opts ...executorOption) *executor {
|
|||
}
|
||||
}
|
||||
for i := 0; i < workerPoolSize; i++ {
|
||||
go worker(e.work)
|
||||
e.workersWG.Add(1)
|
||||
go func() {
|
||||
defer e.workersWG.Done()
|
||||
worker(e.work)
|
||||
}()
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *executor) Close() error {
|
||||
close(e.work)
|
||||
e.workersWG.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue