diff options
author | Devaev Maxim <[email protected]> | 2020-10-15 09:52:55 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-10-15 09:52:55 +0300 |
commit | de2998a42fb65d3207c1cf64e4b42e1d727f846e (patch) | |
tree | 51554de398a328c1605d41ffabd7a1c57001b381 /kvmd/plugins/hid/otg/device.py | |
parent | 04c0743617ad71d7fcc7d661588ef4ad67798ac2 (diff) |
otg hid: clear queue on error
Diffstat (limited to 'kvmd/plugins/hid/otg/device.py')
-rw-r--r-- | kvmd/plugins/hid/otg/device.py | 8 |
1 files changed, 5 insertions, 3 deletions
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: |