From d0e484a66332615bb051259d8f2c8aedc4f4d956 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 3 Oct 2023 16:11:13 +0700 Subject: [PATCH] chore: separate kill subprocess and dispose functions --- electron/core/plugins/inference-plugin/index.js | 2 +- electron/core/plugins/inference-plugin/module.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/electron/core/plugins/inference-plugin/index.js b/electron/core/plugins/inference-plugin/index.js index 6c001d9d2..9f9ec36cc 100644 --- a/electron/core/plugins/inference-plugin/index.js +++ b/electron/core/plugins/inference-plugin/index.js @@ -13,7 +13,7 @@ const dispose = async () => new Promise(async (resolve) => { if (window.electronAPI) { window.electronAPI - .invokePluginFunc(MODULE_PATH, "killSubprocess") + .invokePluginFunc(MODULE_PATH, "dispose") .then((res) => resolve(res)); } }); diff --git a/electron/core/plugins/inference-plugin/module.js b/electron/core/plugins/inference-plugin/module.js index 44205277b..c4da0f627 100644 --- a/electron/core/plugins/inference-plugin/module.js +++ b/electron/core/plugins/inference-plugin/module.js @@ -72,6 +72,11 @@ async function initModel(product) { } function dispose() { + killSubprocess(); + // clean other registered resources here +} + +function killSubprocess() { if (subprocess) { subprocess.kill(); subprocess = null; @@ -83,5 +88,6 @@ function dispose() { module.exports = { initModel, + killSubprocess, dispose, };