summaryrefslogtreecommitdiff
path: root/kvmd/plugins
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-05-18 13:27:15 +0300
committerDevaev Maxim <[email protected]>2021-05-18 13:27:15 +0300
commit9f1182dd1b125966ac1b0299ddb29c2d3dcc7992 (patch)
tree6b15b467e3963a8ca101ab13e8096d1e247dd53d /kvmd/plugins
parent20c88b21703ce0266c0f550cd200772fa908a9bf (diff)
async timeouts
Diffstat (limited to 'kvmd/plugins')
-rw-r--r--kvmd/plugins/ugpio/tesmart.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/kvmd/plugins/ugpio/tesmart.py b/kvmd/plugins/ugpio/tesmart.py
index 8c0e457c..396f1338 100644
--- a/kvmd/plugins/ugpio/tesmart.py
+++ b/kvmd/plugins/ugpio/tesmart.py
@@ -123,8 +123,8 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
(reader, writer) = await self.__ensure_device()
try:
writer.write(b"\xAA\xBB\x03%s\xEE" % (cmd))
- await writer.drain()
- return (await reader.readexactly(6))[4]
+ await asyncio.wait_for(writer.drain(), timeout=self.__timeout)
+ return (await asyncio.wait_for(reader.readexactly(6), timeout=self.__timeout))[4]
except Exception as err:
get_logger(0).error("Can't send command to Tesmart KVM [%s]:%d: %s",
self.__host, self.__port, tools.efmt(err))
@@ -134,10 +134,10 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
async def __ensure_device(self) -> Tuple[asyncio.StreamReader, asyncio.StreamWriter]:
if self.__reader is None or self.__writer is None:
try:
- (reader, writer) = await asyncio.open_connection(self.__host, self.__port)
- sock = writer.get_extra_info("socket")
-# sock.settimeout(self.__timeout)
- sock.settimeout(0)
+ (reader, writer) = await asyncio.wait_for(
+ asyncio.open_connection(self.__host, self.__port),
+ timeout=self.__timeout,
+ )
except Exception as err:
get_logger(0).error("Can't connect to Tesmart KVM [%s]:%d: %s",
self.__host, self.__port, tools.efmt(err))