summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kvmd/clients/streamer.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py
index ea18e5f9..72e2060f 100644
--- a/kvmd/clients/streamer.py
+++ b/kvmd/clients/streamer.py
@@ -31,8 +31,7 @@ from .. import aiotools
# =====
class StreamerError(Exception):
- def __init__(self, err: Exception):
- super().__init__(f"{type(err).__name__}: {err}")
+ pass
# =====
@@ -66,6 +65,11 @@ class StreamerClient:
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
yield (
(frame.headers["X-UStreamer-Online"] == "true"),
int(frame.headers["X-UStreamer-Width"]),
@@ -73,7 +77,8 @@ class StreamerClient:
bytes(await frame.read()),
)
except Exception as err: # Тут бывают и ассерты, и KeyError, и прочая херня из-за корявых исключений в MultipartReader
- raise StreamerError(err)
+ raise StreamerError(f"{type(err).__name__}: {err}")
+ raise StreamerError("Reached EOF")
# async def get_snapshot(self) -> Tuple[bool, bytes]:
# async with self.__make_session(infinite=False) as session: