diff options
author | Maxim Devaev <[email protected]> | 2023-10-26 22:10:46 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-10-26 22:10:46 +0300 |
commit | 1f5ef391350ec13666e3da534de21161f13b9cd8 (patch) | |
tree | 25740059543cd317dea08ce9f824df69003a9ff6 /kvmd | |
parent | 8ef73fabc3741c735503e3b3faac2f178f17723a (diff) |
pikvm/pikvm#1116: fixed tesmart lag, making new tcp connection on every request
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/plugins/ugpio/tesmart.py | 7 |
1 files 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 # ===== |