From 1f5ef391350ec13666e3da534de21161f13b9cd8 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Thu, 26 Oct 2023 22:10:46 +0300 Subject: pikvm/pikvm#1116: fixed tesmart lag, making new tcp connection on every request --- kvmd/plugins/ugpio/tesmart.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kvmd/plugins/ugpio/tesmart.py b/kvmd/plugins/ugpio/tesmart.py index 7eef30de..6c081cdb 100644 --- a/kvmd/plugins/ugpio/tesmart.py +++ b/kvmd/plugins/ugpio/tesmart.py @@ -115,6 +115,7 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute async def cleanup(self) -> None: await self.__close_device() + self.__active = -1 async def read(self, pin: str) -> bool: return (self.__active == int(pin)) @@ -125,8 +126,8 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute assert 1 <= channel <= 16 if state: await self.__send_command("{:c}{:c}".format(1, channel).encode()) - self.__update_notifier.notify() await asyncio.sleep(self.__switch_delay) # Slowdown + self.__update_notifier.notify() # ===== @@ -149,7 +150,10 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute get_logger(0).error("Can't send command to TESmart KVM [%s]:%d: %s", self.__host, self.__port, tools.efmt(err)) await self.__close_device() + self.__active = -1 raise GpioDriverOfflineError(self) + finally: + await self.__close_device() async def __ensure_device(self) -> None: if self.__reader is None or self.__writer is None: @@ -185,7 +189,6 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute await aiotools.close_writer(self.__writer) self.__reader = None self.__writer = None - self.__active = -1 # ===== -- cgit v1.2.3