From 689d08416bdc83733e3edcf931b939aab8791523 Mon Sep 17 00:00:00 2001 From: j433866 Date: Wed, 8 May 2019 10:53:04 +0100 Subject: [PATCH] Don't create more ChefWorkers than we need. --- src/web/WorkerWaiter.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/web/WorkerWaiter.mjs b/src/web/WorkerWaiter.mjs index f5256963..b9385878 100644 --- a/src/web/WorkerWaiter.mjs +++ b/src/web/WorkerWaiter.mjs @@ -148,6 +148,7 @@ class WorkerWaiter { case "bakeError": if (!r.data.hasOwnProperty("progress")) this.app.handleError(r.data.error); this.manager.output.updateOutputError(r.data.error, inputNum, r.data.progress); + this.app.progress = r.data.progress; this.workerFinished(currentWorker); // do more here break; @@ -378,7 +379,11 @@ class WorkerWaiter { this.progress = progress; this.step = step; - for (let i = 0; i < this.maxWorkers; i++) { + let numWorkers = this.maxWorkers; + if (this.inputs.length < numWorkers) { + numWorkers = this.inputs.length; + } + for (let i = 0; i < numWorkers; i++) { const workerIdx = this.addChefWorker(); if (workerIdx === -1) break; this.bakeNextInput(workerIdx);