summaryrefslogtreecommitdiff
path: root/kvmd/clients
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/clients')
-rw-r--r--kvmd/clients/streamer.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py
index 72e2060f..91267bef 100644
--- a/kvmd/clients/streamer.py
+++ b/kvmd/clients/streamer.py
@@ -61,20 +61,24 @@ class StreamerClient:
) as response:
aiotools.raise_not_200(response)
reader = aiohttp.MultipartReader.from_response(response)
+
while True:
frame = await reader.next() # pylint: disable=not-callable
if not isinstance(frame, aiohttp.BodyPartReader):
raise RuntimeError("Expected body part")
+
if hasattr(frame, "_content"):
- # FIXME: An ugly workaround for:
- # Multiple access to StreamReader in eof state, might be infinite loop
if frame._content.is_eof(): # pylint: disable=protected-access
break
+ data = bytes(await frame.read())
+ if not data:
+ break
+
yield (
(frame.headers["X-UStreamer-Online"] == "true"),
int(frame.headers["X-UStreamer-Width"]),
int(frame.headers["X-UStreamer-Height"]),
- bytes(await frame.read()),
+ data,
)
except Exception as err: # Тут бывают и ассерты, и KeyError, и прочая херня из-за корявых исключений в MultipartReader
raise StreamerError(f"{type(err).__name__}: {err}")