Running background python process?


For my plugin Multimodal semantic search - #2 by louis030195 I want to let the semantic search API starts on Obsidian boot, i.e. start the python process in background (and eventually fine-tune the model in real time according to vault change).

My biggest concern is from a permission point of view, kinda ignorant on that point, I use MacOS now, I know a bit more about how it works in Linux though.

  const runModelInBackground = async () => {
    // run bash process and store the handle in settings
    const cmd =
        // eslint-disable-next-line max-len
        `${pythonInterpreter} ${pluginpath}/ --port ${port} --model ${model}`;

    const handle = exec(cmd, (error, stdout, stderr) => {
      console.log(`stdout: ${stdout}`);
      console.log(`stderr: ${stderr}`);
      if (error !== null) {
        console.log(`exec error: ${error}`);
    plugin.api = handle;
    // log
    handle.stdout.on("data", (data) => {
      console.log(`stdout: ${data}`);
    }).on("error", (err) => {
      console.log(`error: ${err}`);
    }).on("close", (code: any) => {
      console.log(`child process exited with code ${code}`);

So can we run background python process in Obsidian plugin API?