From 33677d4c7d91a619efb6e5521a07b5fe2359f116 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 22:37:21 +0000 Subject: [PATCH] fix(supervisor): Gracefully handle connection errors when interacting with supervisor --- devservices/utils/supervisor.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/devservices/utils/supervisor.py b/devservices/utils/supervisor.py index 6403ed8..89c0dee 100644 --- a/devservices/utils/supervisor.py +++ b/devservices/utils/supervisor.py @@ -222,7 +222,12 @@ def _is_program_running(self, program_name: str) -> bool: if not isinstance(state, int): return False return state == SupervisorProcessState.RUNNING - except xmlrpc.client.Fault: + except ( + xmlrpc.client.Fault, + SupervisorConnectionError, + socket.error, + ConnectionRefusedError, + ): # If we can't get the process info, assume it's not running return False @@ -295,6 +300,9 @@ def stop_supervisor_daemon(self) -> None: self._get_rpc_client().supervisor.shutdown() except xmlrpc.client.Fault as e: raise SupervisorError(f"Failed to stop supervisor: {e.faultString}") + except (SupervisorConnectionError, socket.error, ConnectionRefusedError): + # Supervisor is already down, nothing to do + pass def start_process(self, name: str) -> None: if self._is_program_running(name): @@ -315,6 +323,9 @@ def stop_process(self, name: str) -> None: raise SupervisorProcessError( f"Failed to stop process {name}: {e.faultString}" ) + except (SupervisorConnectionError, socket.error, ConnectionRefusedError): + # Supervisor is not available, process is already stopped + pass def get_program_command(self, program_name: str) -> str: opts = ServerOptions()