summaryrefslogtreecommitdiff
path: root/kvmd/clients
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-05-29 19:49:47 +0300
committerDevaev Maxim <[email protected]>2020-05-29 19:49:47 +0300
commit81fec121d08ecea8288b5dd0e39d7ccee8ba4ee3 (patch)
tree14756d744349aec59d048068bbdd40b96aaa45e4 /kvmd/clients
parenta5fcafe2a5a1bd8e18df9b96e2185d1979fc9977 (diff)
new snapshot api
Diffstat (limited to 'kvmd/clients')
-rw-r--r--kvmd/clients/streamer.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py
index 493ac080..1b3f9433 100644
--- a/kvmd/clients/streamer.py
+++ b/kvmd/clients/streamer.py
@@ -54,7 +54,7 @@ class StreamerClient:
async def read_stream(self) -> AsyncGenerator[Tuple[bool, int, int, bytes], None]:
try:
- async with self.__make_http_session(infinite=True) as session:
+ async with self.__make_http_session() as session:
async with session.get(
url=self.__make_url("stream"),
params={"extra_headers": "1"},
@@ -84,24 +84,14 @@ class StreamerClient:
raise StreamerError(f"{type(err).__name__}: {err}")
raise StreamerError("Reached EOF")
-# async def get_snapshot(self) -> Tuple[bool, bytes]:
-# async with self.__make_http_session(infinite=False) as session:
-# async with session.get(self.__make_url("snapshot")) as response:
-# htclient.raise_not_200(response)
-# return (
-# (response.headers["X-UStreamer-Online"] == "true"),
-# bytes(await response.read()),
-# )
-
- def __make_http_session(self, infinite: bool) -> aiohttp.ClientSession:
- kwargs: Dict = {"headers": {"User-Agent": self.__user_agent}}
- if infinite:
- kwargs["timeout"] = aiohttp.ClientTimeout(
+ def __make_http_session(self) -> aiohttp.ClientSession:
+ kwargs: Dict = {
+ "headers": {"User-Agent": self.__user_agent},
+ "timeout": aiohttp.ClientTimeout(
connect=self.__timeout,
sock_read=self.__timeout,
- )
- else:
- kwargs["timeout"] = aiohttp.ClientTimeout(total=self.__timeout)
+ ),
+ }
if self.__unix_path:
kwargs["connector"] = aiohttp.UnixConnector(path=self.__unix_path)
return aiohttp.ClientSession(**kwargs)