Skip to content

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

@lfreneda

Description

@lfreneda

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions