diff options
author | Wolfy-J <[email protected]> | 2018-06-12 23:36:34 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-12 23:36:34 +0300 |
commit | 3126c203b10573f6b834b426edbe2e66b50eb9a2 (patch) | |
tree | 13cf7b879fb7fe6c733929c182f9ada2fb125910 /static_pool.go | |
parent | 47aa87a1cd438c6c99a4640f6af60fd408b5c3bc (diff) |
fixing worker allocation loop
Diffstat (limited to 'static_pool.go')
-rw-r--r-- | static_pool.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/static_pool.go b/static_pool.go index 18bfaf60..24665c01 100644 --- a/static_pool.go +++ b/static_pool.go @@ -169,13 +169,15 @@ func (p *StaticPool) allocateWorker() (w *Worker, err error) { return nil, fmt.Errorf("worker timeout (%s)", p.cfg.AllocateTimeout) case w = <-p.free: timeout.Stop() + if w.State().Value() != StateReady { continue } + return w, nil } } - return w, nil + return nil, fmt.Errorf("all workers are dead (%v)", p.cfg.NumWorkers) } // release releases or replaces the worker. |