![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
batch-cluster
Advanced tools
Efficient, concurrent work via batch-mode command-line tools from within Node.js.
Many command line tools, like ExifTool, PowerShell, and GraphicsMagick, support running in a "batch mode" that accept a series of discrete commands provided through stdin and results through stdout. As these tools can be fairly large, spinning them up can be expensive (especially on Windows).
This module allows you to run a series of commands, or Task
s, processed by a
cluster of these processes.
This module manages both a queue of pending tasks, feeding processes pending tasks when they are idle, as well as monitoring the child processes for errors and crashes. Batch processes are also recycled after processing N tasks or running for N seconds, in an effort to minimize the impact of any potential memory leaks.
As of version 4, retry logic for tasks is a separate concern from this module.
This package powers exiftool-vendored, whose source you can examine as an example consumer.
Depending on your yarn/npm preference:
$ yarn add batch-cluster
# or
$ npm install --save batch-cluster
See CHANGELOG.md.
The child process must use stdin
and stdout
for control/response.
BatchCluster will ensure a given process is only given one task at a time.
Create a singleton instance of BatchCluster.
Note the constructor options takes a union type of
The default logger
writes warning and error messages to console.warn
and console.error
. You
can change this to your logger by using
setLogger or by providing a logger to the BatchCluster
constructor.
Implement the Parser class to parse results from your child process.
Construct or extend the Task class with the desired command and the parser you built in the previous step, and submit it to your BatchCluster's enqueueTask method.
See src/test.ts for an example child process. Note that the script is designed to be flaky on order to test BatchCluster's retry and error handling code.
The default BatchClusterOptions.cleanupChildProcs
value of true
means that BatchCluster will try to use ps
to ensure Node's view of process state are correct, and that errant
processes are cleaned up.
If you run this in a docker image based off Alpine or Debian Slim, this won't work properly unless you install the procps
package.
v13.0.0
💔 Dropped official support for Node v16, which is EOL.
💔 Several methods, including BatchCluster#pids() were changed from async to sync (as they were needlessly async).
📦 A number of timeout options can now be validly 0 to disable timeouts:
spawnTimeoutMillis
taskTimeoutMillis
📦 Added eslint @typescript-eslint/await-thenable
rule and delinted.
📦 Updated development dependencies and rebuilt docs
FAQs
Manage a cluster of child processes
The npm package batch-cluster receives a total of 11,893 weekly downloads. As such, batch-cluster popularity was classified as popular.
We found that batch-cluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.