diff --git a/aiida/engine/daemon/client.py b/aiida/engine/daemon/client.py index c5314e7936..e829c7dae6 100644 --- a/aiida/engine/daemon/client.py +++ b/aiida/engine/daemon/client.py @@ -424,8 +424,8 @@ def call_client(self, command: dict[str, t.Any], timeout: int | None = None) -> if self._is_pid_file_stale: raise DaemonStalePidException( - 'The daemon could not be reached, seemingly because of a stale PID file. Try starting the daemon ' - 'to remove it and restore the daemon.' + 'The daemon could not be reached, seemingly because of a stale PID file. Either stop or start the ' + 'daemon to remove it and restore the daemon to a functional state.' ) from exception if str(exception) == 'Timed out.': @@ -557,6 +557,8 @@ def stop_daemon(self, wait: bool = True, timeout: int | None = None) -> dict[str :raises DaemonTimeoutException: If the connection to the daemon timed out. :raises DaemonException: If the connection to the daemon failed for any other reason. """ + self._clean_potentially_stale_pid_file() + command = {'command': 'quit', 'properties': {'waiting': wait}} response = self.call_client(command, timeout=timeout)