mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 20:26:29 +00: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:
parent
b6bc8b7b7c
commit
d685780a4a
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user