
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@krakenjs/subprocess-robot
Advanced tools
Create subprocesses and deal with messaging. Good for delegating tasks to a differnet process
Before:
import { slowSynchronousTask } from './synchronous-tasks';
export function synchronousTask(options) {
return slowSynchronousTask(options);
}
After:
import { spawnProcess } from 'subprocess-robot';
export async function asynchronousTask(options) {
const { slowSynchronousTask } =
await spawnProcess.import(require.resolve('./synchronous-tasks'));
return await slowSynchronousTask(options);
}
Before:
import { slowSynchronousTask } from './synchronous-tasks';
export function synchronousTask(options) {
return slowSynchronousTask(options);
}
After:
import { spawnProcessPool } from 'subprocess-robot';
export async function asynchronousTask(options) {
const { slowSynchronousTask } =
await spawnProcessPool.import(require.resolve('./synchronous-tasks'));
return await slowSynchronousTask(options);
}
Parent process:
import { spawnProcess } from 'subprocess-robot';
const childProcess = spawnProcess({
script: require.resolve('./child')
});
childProcess.on('getUser', ({ id ) => {
return {
id,
name: 'Daniel',
logout() {
// log the user out
}
}
});
Child process:
import { attachProcess } from 'subprocess-robot';
const parentProcess = attachProcess();
let user = await parentProcess.send('getUser', { id: 1337 });
console.log(`Logging ${ user.name } out`);
await user.logout();
Parent process:
import { spawnProcessPool } from 'subprocess-robot';
const childProcessPool = spawnProcessPool({
script: require.resolve('./child')
});
let result = childProcessPool.send('do_some_blocking_task', data);
Child process:
import { attachProcess } from 'subprocess-robot';
const parentProcess = attachProcess();
parentProcess.on('do_some_blocking_task', data => {
return slowSynchronousCompile(data);
})
Parent process:
import { spawnProcessPool } from 'subprocess-robot';
const childProcessPool = spawnProcessPool();
let { doSomeBlockingTask } = await childProcessPool.import(require.resolve('./blockingTask'));
let result = await doSomeBlockingTask(config);
Child process:
export function doSomeBlockingTask(config) {
return slowSynchronousCompile(config);
}
npm install --save subprocess-robot
Run the tests:
npm test
FAQs
Create processes, process pools, and message between processes
The npm package @krakenjs/subprocess-robot receives a total of 1 weekly downloads. As such, @krakenjs/subprocess-robot popularity was classified as not popular.
We found that @krakenjs/subprocess-robot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.