Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
¿Cómo eliminar un proceso de python generado previamente por 'spawn' en nodeJS?

Actualmente estoy averiguando cómo puedo eliminar un proceso (árbol), pero no puedo encontrar una solución que funcione. Mi sistema es Windows 10. Probé muchas cosas, pero ninguna funciona. Aquí está mi código:

 const { spawn } = require('child_process'); const kill = require('tree-kill'); const path = require('path'); //////////////////////////////////////////////////////////////// const psTree = require('ps-tree'); var killfn = function (pid, signal, callback) { signal = signal || 'SIGKILL'; callback = callback || function () {}; var killTree = true; if (killTree) { psTree(pid, function (err, children) { [pid] .concat( children.map(function (p) { return p.PID; }) ) .forEach(function (tpid) { try { process.kill(tpid, signal); } catch (ex) {} }); callback(); }); } else { try { process.kill(pid, signal); } catch (ex) {} callback(); } }; //////////////////////////////////////////////////////////////// //I spawn the process here: const projectPath = path.join(__dirname, '../'); const pathToPython = path.join(projectPath, '/Venv/Scripts/python'); const pythonOptions = [path.join(projectPath, '/pythonBackend/app.py')]; let ls = spawn(pathToPython, pythonOptions); const endPython = () => { console.log('shutting down python Server...'); // kill(ls.pid); //does not work.... Pyhton Server is still running // ls.kill('SIGINT'); //does not work.. // process.kill(-ls.pid); //does not work; throws error: Uncaught Exception Error: kill ESRCH killfn(ls.pid); //even this does not work... } setTimeout(endPython, 5000);

No sé qué estoy haciendo mal. La aplicación Python todavía se está ejecutando y todas las "soluciones" que encontré en stackoverflow o en otro lugar no funcionan.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!