Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.
Curtis Lowder edited this page Jul 16, 2018 · 3 revisions

Zyspawn

Zyspawn is a NPM package that allows the efficient execution of python code in an isolated environment

Use case

#test.py
def add(x, y):
	return x + y
const {ZygotePool} = require("../zyspawn");
const num_zygotes = 3;
const zyPool = new ZygotePool(num_zygotes, (err)=>{
	let zyInt = zyPool.request();
	zyInt.call("test","add", [1,2], {cwd: __dirname}, (err, output)=>{
		if (err == null) {
			console.log(output.result); // 3
		} else {
			console.log(String(err));
		}
		zyInt.done(()=>{
			zyPool.shutdown((err)=>{
				console.log("Pool is closed");
			});
		});
	});
});
Clone this wiki locally