refactor(dbus): D-Bus interface management with cleanup support.

Introduced a `DbusInterface` base class with a `cleanup` method to
standardize resource cleanup for D-Bus interfaces. Modified
`InterfacePiControl` to inherit from it and implemented `cleanup` logic
for proper watchdog resource handling. Adjusted `BusProvider` to manage
multiple interfaces and ensure cleanup on shutdown.
This commit is contained in:
2025-04-19 15:55:49 +02:00
parent f8bc1532e3
commit 26c3ac0afb
3 changed files with 33 additions and 2 deletions

View File

@@ -7,11 +7,12 @@ from logging import getLogger
from pydbus.generic import signal
from .process_image_helper import PiControlIoctl, ResetDriverWatchdog
from ..dbus_helper import DbusInterface
log = getLogger(__name__)
class InterfacePiControl:
class InterfacePiControl(DbusInterface):
"""
<node>
<interface name='com.revolutionpi.middleware1.picontrol'>
@@ -32,6 +33,9 @@ class InterfacePiControl:
self.wd_reset_driver = ResetDriverWatchdog(self.picontrol_device)
self.wd_reset_driver.register_call(self.notify_reset_driver)
def cleanup(self):
self.wd_reset_driver.stop()
def notify_reset_driver(self):
self.NotifyDriverReset()