From 121200891cca4fe3e062e84438c47129e4b499cf Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 17 Sep 2024 09:18:22 -0400 Subject: [PATCH] Avoid AttributeError if calling stop before start Remove the related pylint disable Signed-off-by: mulhern --- tests/client-dbus/tests/udev/_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/client-dbus/tests/udev/_utils.py b/tests/client-dbus/tests/udev/_utils.py index ee1c6ab3f8..1fc9aa589e 100644 --- a/tests/client-dbus/tests/udev/_utils.py +++ b/tests/client-dbus/tests/udev/_utils.py @@ -325,6 +325,9 @@ class _Service: Start and stop stratisd. """ + def __init__(self): + self._service = None + def start_service(self): """ Starts the stratisd service if it is not already started. Verifies @@ -361,7 +364,7 @@ def start_service(self): "No D-Bus interface for stratisd found although stratisd appears to be running" ) from err - self._service = service # pylint: disable=attribute-defined-outside-init + self._service = service return self def stop_service(self): @@ -369,6 +372,9 @@ def stop_service(self): Stops the stratisd daemon previously spawned. :return: None """ + if self._service is None: + return + self._service.send_signal(signal.SIGINT) self._service.wait(timeout=30) if next(processes("stratisd"), None) is not None: