From de2998a42fb65d3207c1cf64e4b42e1d727f846e Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Thu, 15 Oct 2020 09:52:55 +0300 Subject: otg hid: clear queue on error --- kvmd/plugins/hid/otg/device.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'kvmd/plugins/hid/otg/device.py') diff --git a/kvmd/plugins/hid/otg/device.py b/kvmd/plugins/hid/otg/device.py index 3fad9d3c..43d324b1 100644 --- a/kvmd/plugins/hid/otg/device.py +++ b/kvmd/plugins/hid/otg/device.py @@ -96,13 +96,15 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in event = self.__events_queue.get(timeout=0.1) except queue.Empty: if not self.__udc.can_operate(): + self._clear_queue() self.__close_device() else: - self._process_event(event) + if not self._process_event(event): + self._clear_queue() except Exception: logger.exception("Unexpected HID-%s error", self.__name) + self._clear_queue() self.__close_device() - finally: time.sleep(1) self.__close_device() @@ -112,7 +114,7 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in # ===== - def _process_event(self, event: BaseEvent) -> None: + def _process_event(self, event: BaseEvent) -> bool: raise NotImplementedError def _process_read_report(self, report: bytes) -> None: -- cgit v1.2.3