mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 08:47:49 +00:00
fix(loader): multiprocessing.set_start_method once, queue for plugin import
This commit is contained in:
+1
-1
@@ -10,6 +10,7 @@ from signal import SIGINT, signal
|
|||||||
from sys import exit
|
from sys import exit
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
|
multiprocessing.set_start_method("fork")
|
||||||
|
|
||||||
class PluginWrapper:
|
class PluginWrapper:
|
||||||
def __init__(self, file, plugin_directory, plugin_path) -> None:
|
def __init__(self, file, plugin_directory, plugin_path) -> None:
|
||||||
@@ -87,7 +88,6 @@ class PluginWrapper:
|
|||||||
def start(self):
|
def start(self):
|
||||||
if self.passive:
|
if self.passive:
|
||||||
return self
|
return self
|
||||||
multiprocessing.set_start_method("fork")
|
|
||||||
multiprocessing.Process(target=self._init).start()
|
multiprocessing.Process(target=self._init).start()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@
|
|||||||
},
|
},
|
||||||
"importSort": {
|
"importSort": {
|
||||||
".js, .jsx, .ts, .tsx": {
|
".js, .jsx, .ts, .tsx": {
|
||||||
"style": "module"
|
"style": "module",
|
||||||
|
"parser": "typescript"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class PluginLoader extends Logger {
|
|||||||
private routerHook: RouterHook = new RouterHook();
|
private routerHook: RouterHook = new RouterHook();
|
||||||
private deckyState: DeckyState = new DeckyState();
|
private deckyState: DeckyState = new DeckyState();
|
||||||
|
|
||||||
|
private reloadLock: boolean = false;
|
||||||
|
// stores a list of plugin names which requested to be reloaded
|
||||||
|
private pluginReloadQueue: string[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(PluginLoader.name);
|
super(PluginLoader.name);
|
||||||
this.log('Initialized');
|
this.log('Initialized');
|
||||||
@@ -68,17 +72,33 @@ class PluginLoader extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async importPlugin(name: string) {
|
public async importPlugin(name: string) {
|
||||||
this.log(`Trying to load ${name}`);
|
try {
|
||||||
let find = this.plugins.find((x) => x.name == name);
|
if (this.reloadLock) {
|
||||||
if (find) this.plugins.splice(this.plugins.indexOf(find), 1);
|
this.log('Reload currently in progress, adding to queue', name);
|
||||||
if (name.startsWith('$LEGACY_')) {
|
this.pluginReloadQueue.push(name);
|
||||||
await this.importLegacyPlugin(name.replace('$LEGACY_', ''));
|
return;
|
||||||
} else {
|
}
|
||||||
await this.importReactPlugin(name);
|
|
||||||
}
|
|
||||||
this.log(`Loaded ${name}`);
|
|
||||||
|
|
||||||
this.deckyState.setPlugins(this.plugins);
|
this.log(`Trying to load ${name}`);
|
||||||
|
let find = this.plugins.find((x) => x.name == name);
|
||||||
|
if (find) this.plugins.splice(this.plugins.indexOf(find), 1);
|
||||||
|
if (name.startsWith('$LEGACY_')) {
|
||||||
|
await this.importLegacyPlugin(name.replace('$LEGACY_', ''));
|
||||||
|
} else {
|
||||||
|
await this.importReactPlugin(name);
|
||||||
|
}
|
||||||
|
this.log(`Loaded ${name}`);
|
||||||
|
|
||||||
|
this.deckyState.setPlugins(this.plugins);
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
this.reloadLock = false;
|
||||||
|
const nextPlugin = this.pluginReloadQueue.shift();
|
||||||
|
if (nextPlugin) {
|
||||||
|
this.importPlugin(nextPlugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async importReactPlugin(name: string) {
|
private async importReactPlugin(name: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user