I have a series of python scripts that I want to call via node-cmd in my Node JS application. They rely on each other, so I cannot execute them in parallel. I also cannot use a fixed waiting time, as they always have different execution time. Right now, upon call of my code, all scripts are called at the same time and therefore error... see my code:
pythoncaller: function(req, callback) {
var cmd=require('node-cmd');
cmd.get(`python3 first.py`,
function(err, data, stderr){
console.log(err);
console.log(stderr);
console.log(data);
});
cmd.get(`python3 second.py`,
function(err, data, stderr){
console.log(err);
console.log(stderr);
console.log(data);
});
cmd.get(`python3 third.py"`,
function(err, data, stderr){
console.log(err);
console.log(stderr);
console.log(data);
});
cmd.get(`python3 last.py"`,
function(err, data, stderr){
console.log(err);
console.log(stderr);
console.log(data);
callback(data);
});
},
Do you know a solution on how to execute those scripts not in parallel?