summaryrefslogtreecommitdiff
path: root/static_pool.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-14 15:23:22 +0300
committerValery Piashchynski <[email protected]>2020-10-14 15:23:22 +0300
commita407be25f068a5c0a20a4cf96ddfaf4ccd3af739 (patch)
tree143e1ca6729d28b1d50e151a8d8050ac67e6f5ec /static_pool.go
parentb5f429667131ef91498d67d08242b9f46cc23d6d (diff)
Fixed: race conditions in tests, Handle_Dead test activated
Diffstat (limited to 'static_pool.go')
-rw-r--r--static_pool.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/static_pool.go b/static_pool.go
index 1444e95a..2e72864d 100644
--- a/static_pool.go
+++ b/static_pool.go
@@ -51,7 +51,7 @@ func NewPool(ctx context.Context, cmd func() *exec.Cmd, factory Factory, cfg *Co
events: make(chan PoolEvent),
}
- p.ww = NewWorkerWatcher(func(args ...interface{}) (*SyncWorker, error) {
+ p.ww = NewWorkerWatcher(func(args ...interface{}) (WorkerBase, error) {
w, err := p.factory.SpawnWorkerWithContext(ctx, p.cmd())
if err != nil {
return nil, err
@@ -61,7 +61,7 @@ func NewPool(ctx context.Context, cmd func() *exec.Cmd, factory Factory, cfg *Co
if err != nil {
return nil, err
}
- return &sw, nil
+ return sw, nil
}, p.cfg.NumWorkers, p.events)
workers, err := p.allocateWorkers(ctx, p.cfg.NumWorkers)
@@ -84,10 +84,8 @@ func (p *StaticPool) Config() Config {
}
// Workers returns worker list associated with the pool.
-func (p *StaticPool) Workers(ctx context.Context) (workers []WorkerBase) {
- p.muw.RLock()
- defer p.muw.RUnlock()
- return p.ww.WorkersList(ctx)
+func (p *StaticPool) Workers() (workers []WorkerBase) {
+ return p.ww.WorkersList()
}
func (p *StaticPool) RemoveWorker(ctx context.Context, wb WorkerBase) error {
@@ -136,7 +134,7 @@ func (p *StaticPool) Exec(ctx context.Context, rqs Payload) (Payload, error) {
w.State().Set(StateInvalid)
err = w.Stop(ctx)
if err != nil {
- panic(err)
+ return EmptyPayload, err
}
return p.Exec(ctx, rqs)
}