Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling process.send('complete') more than once #24

Open
lfreneda opened this issue Apr 27, 2016 · 0 comments
Open

Calling process.send('complete') more than once #24

lfreneda opened this issue Apr 27, 2016 · 0 comments

Comments

@lfreneda
Copy link

lfreneda commented Apr 27, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant