diff options
author | Devaev Maxim <[email protected]> | 2020-10-14 19:34:58 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-10-14 22:46:12 +0300 |
commit | 9ba3fdb911c0ff737860a83fb29a6466e80f0296 (patch) | |
tree | d05ec8860c062edeb63e6ea7459ab237f543d9b3 /kvmd/plugins | |
parent | 55968f932866c4e097a32e2d9f6d7764fce1fbee (diff) |
refactoring
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/hid/serial.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py index abb2e87f..a45cd89a 100644 --- a/kvmd/plugins/hid/serial.py +++ b/kvmd/plugins/hid/serial.py @@ -321,6 +321,9 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst self.__queue_event(_MouseWheelEvent(delta_x, delta_y)) def clear_events(self) -> None: + # FIXME: Если очистка производится со стороны процесса хида, то возможна гонка между + # очисткой и добавлением события _ClearEvent. Неприятно, но не смертельно. + # Починить блокировкой после перехода на асинхронные очереди. tools.clear_queue(self.__events_queue) self.__queue_event(_ClearEvent()) @@ -347,19 +350,14 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst if not self.__process_command(tty, event.make_command()): self.clear_events() - except serial.SerialException as err: + except Exception as err: self.clear_events() - if err.errno == errno.ENOENT: + if isinstance(err, serial.SerialException) and err.errno == errno.ENOENT: # pylint: disable=no-member logger.error("Missing HID serial device: %s", self.__device_path) else: logger.exception("Unexpected HID error") time.sleep(1) - except Exception: - self.clear_events() - logger.exception("Unexpected HID error") - time.sleep(1) - def __get_serial(self) -> serial.Serial: return serial.Serial(self.__device_path, self.__speed, timeout=self.__read_timeout) |