node-compute-cluster
node-compute-cluster copied to clipboard
Calling process.send('complete') more than once
Is not possible to call process.send('complete') more than once from workers. Is there an alternative to comunicate with the compute cluster?
For example:
simple.js
#!/usr/bin/env node
const computecluster = require('../lib/compute-cluster');
// allocate a compute cluster
var cc = new computecluster({
module: './simple_worker.js'
});
var toRun = 10;
// then you can perform work in parallel
for (var i = 0; i < toRun; i++) {
cc.enqueue({}, function(err, r) {
if (err) console.log("an error occured:", err);
else console.log("it's nice:", r);
if (--toRun === 0) cc.exit();
});
};
simple_worker.js
process.on('message', function(m) {
process.send('complete');
process.send('complete');
});
the output will be: it's nice: complete 10 times, not 20.