Skip to content

Commit

Permalink
Merge pull request #3688 from mulkieran/avoid-attribute-error-tests
Browse files Browse the repository at this point in the history
Avoid AttributeError if calling stop before start
  • Loading branch information
mulkieran authored Sep 17, 2024
2 parents 9f81e22 + 1212008 commit 2280286
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/client-dbus/tests/udev/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -361,14 +364,17 @@ 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):
"""
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:
Expand Down

0 comments on commit 2280286

Please sign in to comment.