From 40bdc3b7f3313105f3f5efe7c8a02a0040e630fe Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 7 Jan 2023 23:21:59 +0100 Subject: [PATCH] Always wait 5 seconds (regardless of the poll interval) in case of errors. Also, print the error only on the first occurrence, to prevent log spamming. --- platypush/plugins/hid/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/hid/__init__.py b/platypush/plugins/hid/__init__.py index 9705c292a2..6e33e8c3f3 100644 --- a/platypush/plugins/hid/__init__.py +++ b/platypush/plugins/hid/__init__.py @@ -158,9 +158,10 @@ class HidPlugin(RunnablePlugin): device = hid.Device(dev_def['vendor_id'], dev_def['product_id']) # type: ignore data = device.read(data_size) except Exception as e: - self.logger.warning(f'Read error from {path}: {e}') + if device: + self.logger.warning(f'Read error from {path}: {e}') device = None - wait() + sleep(5) continue if not notify_only_if_changed or data != last_data: