From 8c8702c6c9ae6da4c96db633dfb389295a60a988 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Sun, 9 Nov 2025 21:47:20 +0800 Subject: [PATCH] chore: only start runtime process once on Windows --- pkg/plugin/connector.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/plugin/connector.py b/pkg/plugin/connector.py index f3fa159f..dea374f6 100644 --- a/pkg/plugin/connector.py +++ b/pkg/plugin/connector.py @@ -129,16 +129,17 @@ class PluginRuntimeConnector: # We have to launch runtime via cmd but communicate via ws. self.ap.logger.info('(windows) use cmd to launch plugin runtime and communicate via ws') - python_path = sys.executable - env = os.environ.copy() - self.runtime_subprocess_on_windows = await asyncio.create_subprocess_exec( - python_path, - '-m', 'langbot_plugin.cli.__init__', 'rt', - env=env, - ) + if self.runtime_subprocess_on_windows is None: # only launch once + python_path = sys.executable + env = os.environ.copy() + self.runtime_subprocess_on_windows = await asyncio.create_subprocess_exec( + python_path, + '-m', 'langbot_plugin.cli.__init__', 'rt', + env=env, + ) - # hold the process - self.runtime_subprocess_on_windows_task = asyncio.create_task(self.runtime_subprocess_on_windows.wait()) + # hold the process + self.runtime_subprocess_on_windows_task = asyncio.create_task(self.runtime_subprocess_on_windows.wait()) ws_url = 'ws://localhost:5400/control/ws'