summaryrefslogtreecommitdiff
path: root/kvmd/apps/vnc/rfb/__init__.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-05-11 19:35:36 +0300
committerDevaev Maxim <[email protected]>2020-05-11 19:35:36 +0300
commit10f3b5f6a390e176e46d422de4c1e0dcb1816884 (patch)
treedaba50c6578d60442d45595a196ea5a21dc94d05 /kvmd/apps/vnc/rfb/__init__.py
parent98a176f7408350741f89547ea6d1d6e519965cbf (diff)
abort vnc connection
Diffstat (limited to 'kvmd/apps/vnc/rfb/__init__.py')
-rw-r--r--kvmd/apps/vnc/rfb/__init__.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/kvmd/apps/vnc/rfb/__init__.py b/kvmd/apps/vnc/rfb/__init__.py
index 42b762c2..2965bd4d 100644
--- a/kvmd/apps/vnc/rfb/__init__.py
+++ b/kvmd/apps/vnc/rfb/__init__.py
@@ -91,6 +91,9 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute
finally:
for task in tasks:
task.cancel()
+ await asyncio.gather(*tasks, return_exceptions=True)
+ await self._close()
+ get_logger(0).info("Connection closed: %s", self._remote)
async def __wrapper(self, name: str, coro: Coroutine) -> None:
logger = get_logger(0)
@@ -98,23 +101,20 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute
await coro
raise RuntimeError("Subtask just finished without any exception")
except asyncio.CancelledError:
- logger.info("[%s] Client %s: Cancelling ...", name, self._remote)
+ logger.info("[%s] Client %s: Cancelling subtask ...", name, self._remote)
raise
except RfbConnectionError as err:
- logger.info("[%s] Client %s: Gone (%s): Disconnected", name, self._remote, str(err))
+ logger.info("[%s] Client %s: Gone: %s", name, self._remote, str(err))
except (RfbError, ssl.SSLError) as err:
- logger.error("[%s] Client %s: %s: Disconnected", name, self._remote, str(err))
+ logger.error("[%s] Client %s: Error: %s", name, self._remote, str(err))
except Exception:
- logger.exception("[%s] Unhandled exception with client %s: Disconnected", name, self._remote)
+ logger.exception("[%s] Unhandled exception with client %s", name, self._remote)
async def __main_task_loop(self) -> None:
- try:
- await self.__handshake_version()
- await self.__handshake_security()
- await self.__handshake_init()
- await self.__main_loop()
- finally:
- self._close()
+ await self.__handshake_version()
+ await self.__handshake_security()
+ await self.__handshake_init()
+ await self.__main_loop()
# =====