X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=src%2Fworker.js;h=4f566ad9f97209bcc538692cf87b6e412ccbe877;hb=fe3a4d96d559edcc30c2047109cd7b027e6258eb;hp=9b6fd7ab882752f00dc76ae693db8980e8eadc76;hpb=6fd633b452ab3baed459d78b7ec29848bceea4ee;p=websub-hub diff --git a/src/worker.js b/src/worker.js index 9b6fd7a..4f566ad 100644 --- a/src/worker.js +++ b/src/worker.js @@ -42,6 +42,7 @@ class Worker { this.inFlight = []; // Our work heap of Promises this.nextTimeout = undefined; // Allow clearTimeout() to reset waiting period. this.running = false; + this.isProcessing = false; // Only let one process() method execute on the work heap at a time } /** @@ -177,7 +178,13 @@ class Worker { async process() { const _scope = _fileScope('process'); - this.logger.debug(_scope, 'called', {}); + this.logger.debug(_scope, 'called', { isProcessing: this.isProcessing }); + + + if (this.isProcessing) { + return; + } + this.isProcessing = true; // Interrupt any pending sleep, if we were called out of timeout-cycle. clearTimeout(this.nextTimeout); @@ -218,6 +225,8 @@ class Worker { // No more work, wait a while and retry this._recurr(); + + this.isProcessing = false; } }