From e684ac16035bed9a4c09677b0db3b33477955dc9 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Wed, 24 Feb 2021 00:12:05 +0300 Subject: Fix pool behavior, update tests --- pkg/pool/static_pool.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pkg/pool/static_pool.go') diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index f1b20bb9..0617cbc0 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -168,16 +168,16 @@ func (sp *StaticPool) Exec(p payload.Payload) (payload.Payload, error) { } // Be careful, sync with pool.Exec method -func (sp *StaticPool) ExecWithContext(ctx context.Context, p payload.Payload) (payload.Payload, error) { +func (sp *StaticPool) execWithTTL(ctx context.Context, p payload.Payload) (payload.Payload, error) { const op = errors.Op("static_pool_exec_with_context") - ctxGetFree, cancel := context.WithTimeout(ctx, sp.cfg.AllocateTimeout) + ctxAlloc, cancel := context.WithTimeout(ctx, sp.cfg.AllocateTimeout) defer cancel() - w, err := sp.getWorker(ctxGetFree, op) + w, err := sp.getWorker(ctxAlloc, op) if err != nil { return payload.Payload{}, errors.E(op, err) } - rsp, err := w.(worker.SyncWorker).ExecWithTimeout(ctx, p) + rsp, err := w.(worker.SyncWorker).ExecWithTTL(ctx, p) if err != nil { return sp.err_encoder(err, w) } @@ -185,7 +185,7 @@ func (sp *StaticPool) ExecWithContext(ctx context.Context, p payload.Payload) (p // worker want's to be terminated if len(rsp.Body) == 0 && toString(rsp.Context) == StopRequest { sp.stopWorker(w) - return sp.ExecWithContext(ctx, p) + return sp.execWithTTL(ctx, p) } err = sp.checkMaxJobs(w) -- cgit v1.2.3