diff options
author | Devaev Maxim <[email protected]> | 2021-05-16 05:57:08 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-05-16 05:57:08 +0300 |
commit | 8db0ab20e0fda9796e7b3607a551e90317dfba71 (patch) | |
tree | 12db6f56df3b0b495b2d54eb16d15f2db2574bad /kvmd/apps | |
parent | 1fc8434f0a6c7c8730c8ee5a4752fb075e190fcd (diff) |
tesmart rewrite
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/ugpio.py | 2 | ||||
-rw-r--r-- | kvmd/apps/vnc/rfb/stream.py | 16 | ||||
-rw-r--r-- | kvmd/apps/vnc/server.py | 3 |
3 files changed, 5 insertions, 16 deletions
diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py index d77a81c6..ca04b31f 100644 --- a/kvmd/apps/kvmd/ugpio.py +++ b/kvmd/apps/kvmd/ugpio.py @@ -295,7 +295,7 @@ class UserGpio: async def cleanup(self) -> None: for driver in self.__drivers.values(): try: - driver.cleanup() + await driver.cleanup() except Exception: get_logger().exception("Can't cleanup driver %s", driver) diff --git a/kvmd/apps/vnc/rfb/stream.py b/kvmd/apps/vnc/rfb/stream.py index 3f2d38b8..235a32e4 100644 --- a/kvmd/apps/vnc/rfb/stream.py +++ b/kvmd/apps/vnc/rfb/stream.py @@ -27,6 +27,8 @@ import struct from typing import Tuple from typing import Any +from .... import aiotools + from .errors import RfbConnectionError @@ -35,18 +37,6 @@ def rfb_format_remote(writer: asyncio.StreamWriter) -> str: return "[%s]:%d" % (writer.transport.get_extra_info("peername")[:2]) -async def rfb_close_writer(writer: asyncio.StreamWriter) -> bool: - closing = writer.is_closing() - if not closing: - writer.transport.abort() # type: ignore - writer.close() - try: - await writer.wait_closed() - except Exception: - pass - return (not closing) - - class RfbClientStream: def __init__(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None: self.__reader = reader @@ -145,4 +135,4 @@ class RfbClientStream: self.__writer = ssl_writer async def _close(self) -> None: - await rfb_close_writer(self.__writer) + await aiotools.close_writer(self.__writer) diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index ca391292..57c111ef 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -55,7 +55,6 @@ from ... import aiotools from .rfb import RfbClient from .rfb.stream import rfb_format_remote -from .rfb.stream import rfb_close_writer from .rfb.errors import RfbError from .vncauth import VncAuthKvmdCredentials @@ -487,7 +486,7 @@ class VncServer: # pylint: disable=too-many-instance-attributes except Exception: logger.exception("[entry] %s: Unhandled exception in client task", remote) finally: - if (await rfb_close_writer(writer)): + if (await aiotools.close_writer(writer)): logger.info("[entry] %s: Connection is closed in an emergency", remote) self.__handle_client = handle_client |