mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
fixed race conditions on hid events cleanup
This commit is contained in:
parent
28cc3fe99a
commit
6c35dd413d
@ -126,7 +126,10 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in
|
|||||||
|
|
||||||
def _clear_queue(self) -> None:
|
def _clear_queue(self) -> None:
|
||||||
while not self.__events_queue.empty():
|
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:
|
def _ensure_write(self, report: bytes, reopen: bool=False, close: bool=False) -> bool:
|
||||||
if reopen:
|
if reopen:
|
||||||
|
|||||||
@ -298,7 +298,10 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst
|
|||||||
|
|
||||||
def clear_events(self) -> None:
|
def clear_events(self) -> None:
|
||||||
while not self.__events_queue.empty():
|
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())
|
self.__queue_event(_ClearEvent())
|
||||||
|
|
||||||
def __queue_event(self, event: _BaseEvent) -> None:
|
def __queue_event(self, event: _BaseEvent) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user