0

I have an infinite loop that runs 2 functions, but when I run the loop it only executes the functions once. Does anyone know why?

This is the loop

while(true){
  await getPorticoPulseira();
  await sleep(3000);
}  

This is the sleep function

function sleep(ms){
    return new Promise( resolve => setTimeout(resolve,ms) );
}

This is the getPorticoPulseira function

function getPorticoPulseira() {
   return new Promise(function (resolve, reject) {
    var { PythonShell } = require("python-shell");
    var path = require("path");

    var options = {
        scriptPath: path.join(__dirname, "../_engine/"),
    };

    var readrfid = new PythonShell("lerpulseira.py", options);

    var nrseriepulseira = 0;
    readrfid.on("message", function (message) {
        console.log(message);
        nrseriepulseira = message;
    });
});

}

rdas
  • 20,604
  • 6
  • 33
  • 46

0 Answers0