Open krzysztofantczak opened 9 years ago
I think there is some kind of issue with pool.kill() it seems that not everything is cleaned up properly. I've created a repository to illustrate that issue https://github.com/tradero/sanctum/blob/master/playground/tofix_timeout_issue.js - not sure what exactly is responsible for that behaviour thought.
And here is how i'm using sandcastle https://github.com/tradero/sanctum/blob/master/lib/index.js
@krzysztofantczak in the simple case, it seems as though the pool exists appropriately, e.g.,
it('should run scripts on non blocking instances', function (finished) {
var pool = new Pool({numberOfInstances: 2});
var exited = false;
// Create blocking script.
var script = pool.createScript("\
exports.main = function() {\n\
while(true);\
}\n\
"
);
script.run();
var scriptsExited = 0;
for (var i = 0; i < 10; ++i) {
var script2 = pool.createScript("\
exports.main = function() {\n\
exit(10);\n\
}\n\
"
);
script2.on('exit', function (err, result) {
scriptsExited++;
if (scriptsExited == 10) {
pool.kill();
equal(10, result);
exited = true;
finished();
}
});
script2.run();
}
setTimeout(function () {
if (!exited) {
equal(false, true);
}
}, 3000);
});
It would be great to try to simplify your test case a bit, and get some sample code around the pool failing to exit.
Hi,
Is there any way to forcefully shutdown pool of workers by killing all pending tasks/scripts and start new pool which can be used again (with empty queue)?