1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-05-08 17:08:36 +01:00

Fix IncompleteReadError happening sometimes when reading Systemd logs (#4974)

Sometimes an empty line is returned from readuntil when EOF is reached,
which seems to be caused by a race of the EOF check in the loop and
later check in readuntil. With this fix, I am not able to reproduce the
issue anymore.
This commit is contained in:
Jan Čermák
2024-03-21 15:58:53 +01:00
committed by GitHub
parent b6bc8b7b7c
commit d685780a4a
+5 -3
View File
@@ -75,9 +75,11 @@ async def journal_logs_reader(
entries: dict[str, str] = {}
while not resp.content.at_eof():
line = await resp.content.readuntil(b"\n")
# newline means end of message:
if line == b"\n":
yield formatter_(entries)
# newline means end of message, also empty line is sometimes returned
# at EOF (likely race between at_eof and EOF check in readuntil)
if line == b"\n" or not line:
if entries:
yield formatter_(entries)
entries = {}
continue