summaryrefslogtreecommitdiff
path: root/kvmd/plugins/hid
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-08-18 10:57:02 +0300
committerDevaev Maxim <[email protected]>2020-08-18 10:57:02 +0300
commit6c35dd413dce63d811f996f99adb87e6615a2baf (patch)
tree1515c6d27c207aaca97972efbeb3693b36a7ad21 /kvmd/plugins/hid
parent28cc3fe99a3e90213f1f01286b5ec55f4f06224c (diff)
fixed race conditions on hid events cleanup
Diffstat (limited to 'kvmd/plugins/hid')
-rw-r--r--kvmd/plugins/hid/otg/device.py5
-rw-r--r--kvmd/plugins/hid/serial.py5
2 files changed, 8 insertions, 2 deletions
diff --git a/kvmd/plugins/hid/otg/device.py b/kvmd/plugins/hid/otg/device.py
index 44c286cb..45681aba 100644
--- a/kvmd/plugins/hid/otg/device.py
+++ b/kvmd/plugins/hid/otg/device.py
@@ -126,7 +126,10 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in
def _clear_queue(self) -> None:
while not self.__events_queue.empty():
- self.__events_queue.get_nowait()
+ try:
+ self.__events_queue.get_nowait()
+ except queue.Empty:
+ break
def _ensure_write(self, report: bytes, reopen: bool=False, close: bool=False) -> bool:
if reopen:
diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py
index 752870d7..cee0048d 100644
--- a/kvmd/plugins/hid/serial.py
+++ b/kvmd/plugins/hid/serial.py
@@ -298,7 +298,10 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst
def clear_events(self) -> None:
while not self.__events_queue.empty():
- self.__events_queue.get_nowait()
+ try:
+ self.__events_queue.get_nowait()
+ except queue.Empty:
+ break
self.__queue_event(_ClearEvent())
def __queue_event(self, event: _BaseEvent) -> None: