Skip to content

Commit 513830b

Browse files
unkcpzsphuber
authored andcommitted
DaemonClient: Clean stale PID file in stop_daemon (#6007)
The daemon client was recently refactored to only clean the stale PID file in the `start_daemon` command. Before it was done when asking the status which was considered an unexpected side-effect. Sometimes, the user wants to make sure the daemon is no longer running. Currently, the status would raise a warning if a stale PID file is found suggesting the user to start the daemon to fix it. However, this is counterintuitve and not desirable if the goal is for the daemon to be stopped. The `stop_daemon` method is updated to also clean any potentially stale PID files. The error message is updated to suggest to either start or stop the daemon to return it to a nominal state. Co-authored-by: Sebastiaan Huber <[email protected]> Cherry-pick: 2bfc3c6
1 parent fce1cd6 commit 513830b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

aiida/engine/daemon/client.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ def call_client(self, command: dict[str, t.Any], timeout: int | None = None) ->
424424

425425
if self._is_pid_file_stale:
426426
raise DaemonStalePidException(
427-
'The daemon could not be reached, seemingly because of a stale PID file. Try starting the daemon '
428-
'to remove it and restore the daemon.'
427+
'The daemon could not be reached, seemingly because of a stale PID file. Either stop or start the '
428+
'daemon to remove it and restore the daemon to a functional state.'
429429
) from exception
430430

431431
if str(exception) == 'Timed out.':
@@ -557,6 +557,8 @@ def stop_daemon(self, wait: bool = True, timeout: int | None = None) -> dict[str
557557
:raises DaemonTimeoutException: If the connection to the daemon timed out.
558558
:raises DaemonException: If the connection to the daemon failed for any other reason.
559559
"""
560+
self._clean_potentially_stale_pid_file()
561+
560562
command = {'command': 'quit', 'properties': {'waiting': wait}}
561563
response = self.call_client(command, timeout=timeout)
562564

0 commit comments

Comments
 (0)