Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Kill PythonShell.run() script when condition is met, and start another script

My question is essentially the title. I currently have a file/module for running python scripts. Lets call it script.js which looks like this:

const PythonShell = require('python-shell').PythonShell;

class AHK {
   static async runScript() {
    PythonShell.run('/ahk/runScript.py', null, function (err) {
      if (err) throw err;
      console.log('finished');
    });
  }

  static async runOtherScript() {
    PythonShell.run('/ahk/runOtherScript.py', null, function (err) {
      if (err) throw err;
      console.log('finished');
    });
  }
}

module.exports = AHK;

I have my main.js file which imports this module and executes the function and looks like this:

const AHK = require("./ahk");

AHK.runScript();

Right now I have the python script ending after a certain amount of time. I'd like to have it so I can run the python script until something changes on the js side, kill that script, and then start the other one. Pseudo code for this would be something like:

const AHK = require("./ahk");

AHK.runScript();

if(requirement = true){
// kill AHK.runScript() here
// start AHK.runOtherScript();
}

or something along this line

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda