我在谷歌上搜索了一下,但找不到一个合适的答案,我不得不说我是一个相当新手的re NodeJS和electron:我的问题是我已经用Python-Shell连接了我的电子应用程序和flask,但当我关闭我的应用程序时,即使关闭终端,flask仍然在后台运行。在
这是我将应用程序连接到flask的方式:var pyshell = require('python-shell');
pyshell.PythonShell.run('engine.py', function (err, results) {
if (err) console.log(err);
});
有没有办法“取消运行”(关闭、退出、杀死)pyshell?
我试过了,但没用:
^{2}$
这是完整的代码,很短,可能有助于识别问题:const {app, BrowserWindow} = require('electron')
function createWindow () {
window = new BrowserWindow({width: 800, height: 600})
window.loadFile('index.html')
var pyshell = require('python-shell');
pyshell.PythonShell.run('engine.py', function (err, results) {
if (err) console.log(err);
});
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
pyshell.kill('engine.py'); //
app.quit()
}
})