javascript - How to kill a Python-Shell module process in Node.js? -
i using python-shell module in node based web interface. issue having syntactical. code below shows generation of python script.
var pythonshell = require('python-shell'); pythonshell.run('my_script.py' function (err) { if (err) throw err; console.log('finished'); }):
this example script here. how relate node's
var procc = require('child_process'.spawn('mongod'); procc.kill('sigint');
the documentation states pythonshell instances have following properties:
childprocess: process instance created via child_process.spawn
but how acutally use this? there seems lack of examples when comes specific module
for example -
var python_process; router.get('/start_python', function(req, res) { var pythonshell = require('python-shell'); var pyshell = new pythonshell('general.py'); pyshell.end(function (err) { if (err) { console.log(err); } }); python_process = pyshell.childprocess; res.send('started.'); }); router.get('/stop_python', function(req, res) { python_process.kill('sigint'); res.send('stopped'); });
Comments
Post a Comment