summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-05-25 22:49:19 +0300
committerDevaev Maxim <[email protected]>2020-05-25 22:49:19 +0300
commitbedf542d9bb781fec30866cafd737a149fd192b6 (patch)
treedecde4b9b232c998ec616165351fe017711150d3 /kvmd
parent9bfc09a265bb63ac8253bc2b3c03f23807dc0204 (diff)
An ugly workaround for "Multiple access to StreamReader in eof state, might be infinite loop"
Diffstat (limited to 'kvmd')
-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: