Фикс controlplane

This commit is contained in:
2026-03-09 19:36:46 +03:00
parent fa8ac463a0
commit 680a56edfb

View File

@@ -65,7 +65,12 @@ class RuntimeManager:
if not self._started: if not self._started:
return return
self._state = LifecycleState.STOPPING self._state = LifecycleState.STOPPING
try:
self.workers.stop(timeout=timeout, force=force) self.workers.stop(timeout=timeout, force=force)
except TimeoutError:
# Do not leave runtime in STOPPING forever for control-plane callers.
self.workers.stop(force=True)
finally:
if stop_control_plane: if stop_control_plane:
self.control_plane.stop() self.control_plane.stop()
self._started = False self._started = False
@@ -85,13 +90,15 @@ class RuntimeManager:
async def start_runtime(self) -> str: async def start_runtime(self) -> str:
if self._started: if self._started:
return "runtime already running" return "runtime already running"
if self.workers.lifecycle_state() == LifecycleState.STOPPING:
return "runtime is stopping"
self.start(start_control_plane=False) self.start(start_control_plane=False)
return "runtime started" return "runtime started"
async def stop_runtime(self) -> str: async def stop_runtime(self) -> str:
if not self._started: if not self._started:
return "runtime already stopped" return "runtime already stopped"
self.stop(stop_control_plane=False) self.stop(timeout=0.0, stop_control_plane=False)
return "runtime stopped" return "runtime stopped"
async def runtime_status(self) -> str: async def runtime_status(self) -> str: