summaryrefslogtreecommitdiff
path: root/kvmd/clients
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-07-19 16:25:31 +0300
committerMaxim Devaev <[email protected]>2022-07-19 16:25:31 +0300
commitb16359c53e5dd62839a9af0fa14bdb9c5f350c75 (patch)
tree198d7e7d517ee2c8fbd6f5cca7b83ffda629ab5b /kvmd/clients
parent54cb5e1fed2ad2e0f291adcc6738659fd15dc452 (diff)
handle closing ws event
Diffstat (limited to 'kvmd/clients')
-rw-r--r--kvmd/clients/kvmd.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py
index 84576fb2..b4585bcc 100644
--- a/kvmd/clients/kvmd.py
+++ b/kvmd/clients/kvmd.py
@@ -153,6 +153,8 @@ class KvmdClientWs:
msg = receive_task.result()
if msg.type == aiohttp.WSMsgType.TEXT:
yield json.loads(msg.data)
+ elif msg.type == aiohttp.WSMsgType.CLOSE:
+ await self.__ws.close()
elif msg.type == aiohttp.WSMsgType.CLOSED:
break
else:
@@ -167,6 +169,10 @@ class KvmdClientWs:
receive_task.cancel()
if writer_task:
writer_task.cancel()
+ try:
+ await self.__ws.close()
+ except Exception:
+ pass
self.__communicated = False
async def send_key_event(self, key: str, state: bool) -> None: