From 7d90b274ae8f06dd3606d3fd5529f75db1c2dc6d Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 7 Jan 2023 23:48:02 +0100 Subject: [PATCH 1/2] Make sure that any existing device monitor is terminated upon disconnection --- platypush/plugins/hid/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/hid/__init__.py b/platypush/plugins/hid/__init__.py index 6e33e8c3f..7c9ac5fb6 100644 --- a/platypush/plugins/hid/__init__.py +++ b/platypush/plugins/hid/__init__.py @@ -213,7 +213,6 @@ class HidPlugin(RunnablePlugin): for path in new_device_paths: device = scanned_devices[path] get_bus().post(HidDeviceConnectedEvent(**device)) - monitor_rule = self._get_monitor_rule(device) if monitor_rule: self._register_device_monitor(device, monitor_rule) @@ -227,7 +226,10 @@ class HidPlugin(RunnablePlugin): lost_device_paths = available_device_paths.difference(scanned_device_paths) for path in lost_device_paths: - get_bus().post(HidDeviceDisconnectedEvent(**self._available_devices[path])) + device = self._available_devices.get(path) + if device: + get_bus().post(HidDeviceDisconnectedEvent(**device)) + self._unregister_device_monitor(device['path']) def _handle_device_events(self, scanned_devices: dict): """ From 2893cb1cc40fdb95db3b9148a4c7e70257a7af26 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 8 Jan 2023 00:15:24 +0100 Subject: [PATCH 2/2] Replaced deprecated `missing` marshmallow parameter with `load_default` --- platypush/schemas/hid.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platypush/schemas/hid.py b/platypush/schemas/hid.py index 6cb372cae..3cfee402d 100644 --- a/platypush/schemas/hid.py +++ b/platypush/schemas/hid.py @@ -50,7 +50,7 @@ class HidDeviceSchema(Schema): class HidMonitoredDeviceSchema(HidDeviceSchema): notify_only_if_changed = fields.Boolean( - missing=True, + load_default=True, metadata={ 'description': 'If set to true (default), only changes in the ' 'values of the device will trigger events. So if you are e.g. ' @@ -60,7 +60,7 @@ class HidMonitoredDeviceSchema(HidDeviceSchema): ) data_size = fields.Integer( - missing=64, + load_default=64, metadata={ 'description': 'How many bytes should be read from the device on ' 'each iteration (default: 64)', @@ -68,7 +68,7 @@ class HidMonitoredDeviceSchema(HidDeviceSchema): ) poll_seconds = fields.Float( - missing=0, + load_default=0, metadata={ 'description': 'How often we should wait before data reads ' '(default: no wait)'