From: Jérôme Benoit Date: Wed, 23 Aug 2023 22:46:44 +0000 (+0200) Subject: refactor: cleanup tasks redistribution on error code X-Git-Tag: v2.6.34~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=58baffd328c308bbffed882ebdc8bb68b8198b26;p=poolifier.git refactor: cleanup tasks redistribution on error code Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index c6712d19..7b0d541d 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1194,29 +1194,21 @@ export abstract class AbstractPool< let minQueuedTasks = Infinity let executeTask = false for (const [workerNodeId, workerNode] of this.workerNodes.entries()) { - if ( - workerNode.info.ready && - workerNodeId !== workerNodeKey && - workerNode.usage.tasks.executing < + if (workerNode.info.ready && workerNodeId !== workerNodeKey) { + if ( + workerNode.usage.tasks.executing < (this.opts.tasksQueueOptions?.concurrency as number) - ) { - executeTask = true - } - if ( - workerNode.info.ready && - workerNodeId !== workerNodeKey && - workerNode.usage.tasks.queued === 0 - ) { - destinationWorkerNodeKey = workerNodeId - break - } - if ( - workerNode.info.ready && - workerNodeId !== workerNodeKey && - workerNode.usage.tasks.queued < minQueuedTasks - ) { - minQueuedTasks = workerNode.usage.tasks.queued - destinationWorkerNodeKey = workerNodeId + ) { + executeTask = true + } + if (workerNode.usage.tasks.queued === 0) { + destinationWorkerNodeKey = workerNodeId + break + } + if (workerNode.usage.tasks.queued < minQueuedTasks) { + minQueuedTasks = workerNode.usage.tasks.queued + destinationWorkerNodeKey = workerNodeId + } } } const task = {