diff options
author | Devaev Maxim <[email protected]> | 2020-05-25 22:49:19 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-25 22:49:19 +0300 |
commit | bedf542d9bb781fec30866cafd737a149fd192b6 (patch) | |
tree | decde4b9b232c998ec616165351fe017711150d3 | |
parent | 9bfc09a265bb63ac8253bc2b3c03f23807dc0204 (diff) |
An ugly workaround for "Multiple access to StreamReader in eof state, might be infinite loop"
-rw-r--r-- | kvmd/clients/streamer.py | 11 |
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: |