How to use worker-farm - 10 common examples

To help you get started, we’ve selected a few worker-farm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / bin / packages / build.js View on Github external
if ( error ) {
			// If an error occurs, the process can't be ended immediately since
			// other workers are likely pending. Optimally, it would end at the
			// earliest opportunity (after the current round of workers has had
			// the chance to complete), but this is not made directly possible
			// through `worker-farm`. Instead, ensure at least that when the
			// process does exit, it exits with a non-zero code to reflect the
			// fact that an error had occurred.
			process.exitCode = 1;

			console.error( error );
		}

		if ( ended && ++complete === files.length ) {
			workerFarm.end( worker );
		}
	} ) )
	.on( 'end', () => ended = true )
github trivago / parallel-webpack / __tests__ / index.spec.js View on Github external
it('should call generate workers and return farm promise', () => {
            jest.spyOn(console, 'log').mockImplementation(() => {});
            promisify.mockReturnValueOnce(jest.fn());

            const returnPromise = run('testConfig.js', { colors: false }, jest.fn());
            expect(workerFarm.mock.calls[0][0]).toEqual({ maxRetries: 0 });

            expect(returnPromise).toBe(Bluebird);
            expect(promisify).toHaveBeenCalledTimes(1);
            expect(error).toHaveBeenCalledTimes(1);
            expect(then).toHaveBeenCalledTimes(2);
            expect(Bluebird.finally).toHaveBeenCalledTimes(1);
            expect(asCallback).toHaveBeenCalledTimes(1);
        });
github electron-userland / electron-builder / test / src / helpers / lint.ts View on Github external
async function main(): Promise {
  const packages = (await fs.readdir(packageDir)).filter(it => !it.includes(".")).sort()
  for (const name of packages) {
    if (name.includes("electron-forge-maker-") || name.includes("electron-installer-")) {
      continue
    }

    workers(path.join(packageDir, name), (error: Error, hasError: boolean) => {
      if (hasError) {
        process.exitCode = 1
      }
    })
  }
  workerFarm.end(workers)
}
github gemini-testing / gemini / lib / state-processor / state-processor.js View on Github external
        emitter.on(Events.END, () => workerFarm.end(this._workers));
    }
github gemini-testing / gemini / lib / image-processor / index.js View on Github external
emitter.on(RunnerEvents.END, function() {
            workerFarm.end(this._workers);
        }.bind(this));
    },
github Fitbit / webpack-cluster / lib / workerFarmRunCompilerStrategy.js View on Github external
WorkerFarmRunCompilerStrategy.prototype.close = function() {
    workerFarm.end(this.workers);
};
github antwarjs / antwar / packages / antwar / src / build / build.js View on Github external
}, function (err) {
      log('Tasks finished');

      workerFarm.end(workers);

      if (err) {
        return reject(err);
      }

      return resolve();
    });
  });
github cliffano / datagen / lib / datagen.js View on Github external
function endWorkerFarm() {
    workerFarm.end(worker);
  }
github jamesshore / automatopia / node_modules / simplebuild-jshint / src / jshint_runner.js View on Github external
function reduceIt(err, results) {
			if (workers) workerFarm.end(workers);
			if (err) return callback(err);

			var pass = results.reduce(function(pass, result) {
				return pass && result;
			}, true);

			process.stdout.write("\n");
			return callback(null, pass);
		}
	};
github Kikobeats / farm-cli / bin / index.js View on Github external
function closeFarm () {
  workerFarm.end(spawnWorker)
}

worker-farm

Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options.

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis