summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-04-08 17:03:19 +0300
committerDevaev Maxim <[email protected]>2019-04-08 17:03:19 +0300
commitdda30309a48370bb3d82c8723993490972613223 (patch)
treea0a9fe56991adfe1a688d357a1fc437e1a2e9b10 /kvmd
parentd2559c26b631d7defc880a912e9e6f4a2ff98a77 (diff)
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/streamer.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py
index bf1361f0..84eb68a2 100644
--- a/kvmd/apps/kvmd/streamer.py
+++ b/kvmd/apps/kvmd/streamer.py
@@ -117,11 +117,11 @@ class Streamer: # pylint: disable=too-many-instance-attributes
return dict(self.__params)
async def get_state(self) -> Dict:
- self.__ensure_session()
+ session = self.__ensure_session()
url = "http://%s:%d/state" % (self.__host, self.__port)
state = None
try:
- async with self.__http_session.get(url, timeout=self.__timeout) as response: # type: ignore
+ async with session.get(url, timeout=self.__timeout) as response:
response.raise_for_status()
state = (await response.json())["result"]
except (aiohttp.ClientConnectionError, aiohttp.ServerConnectionError):
@@ -158,12 +158,13 @@ class Streamer: # pylint: disable=too-many-instance-attributes
await self.__http_session.close()
self.__http_session = None
- def __ensure_session(self) -> None:
+ def __ensure_session(self) -> aiohttp.ClientSession:
if not self.__http_session:
if self.__unix_path:
self.__http_session = aiohttp.ClientSession(connector=aiohttp.UnixConnector(path=self.__unix_path))
else:
self.__http_session = aiohttp.ClientSession()
+ return self.__http_session
async def __inner_start(self) -> None:
assert not self.__streamer_task