diff --git a/src/plugins/controller.py b/src/plugins/controller.py index 429a60f..805baf5 100644 --- a/src/plugins/controller.py +++ b/src/plugins/controller.py @@ -3,7 +3,8 @@ import os import sys import importlib import traceback -import asyncio + +from concurrent.futures import ThreadPoolExecutor from os.path import join from os.path import isdir @@ -76,13 +77,10 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi module = self._load_plugin_module(path, folder, target) if is_pre_launch: - asyncio.run( - self.execute_plugin(module, manifest_meta) - ) + self._run_with_pool(module, manifest_meta) else: GLib.idle_add( - asyncio.run, - self.execute_plugin(module, manifest_meta) + self._run_with_pool, module, manifest_meta ) except Exception as e: logger.info(f"Malformed Plugin: Not loading -->: '{folder}' !") @@ -90,6 +88,10 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi os.chdir(parent_path) + def _run_with_pool(self, module: type, manifest_meta: ManifestMeta): + with ThreadPoolExecutor(max_workers = 1) as executor: + executor.submit(self.execute_plugin, module, manifest_meta) + def _load_plugin_module(self, path, folder, target): os.chdir(path) @@ -125,7 +127,7 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi manifest_metas: list = self._manifest_manager.get_post_launch_plugins() self._load_plugins(manifest_metas) - async def execute_plugin(self, module: type, manifest_meta: ManifestMeta): + def execute_plugin(self, module: type, manifest_meta: ManifestMeta): plugin = module.Plugin() plugin.plugin_context: PluginContext = self.create_plugin_context()