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 24, 2018 · 3 revisions

Zyspawn

Zyspawn is a NPM package that allows the efficient execution of python code in an clean environment. Currently, it is used to allow for fast execution of python code for PrairieLearn. It does not allow for safe execution of code in isolated environments.

Example

#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