9
0
Fork 0

Fix state reporting

This commit is contained in:
Lauri Võsandi 2022-11-07 22:22:31 +02:00
parent 4c2ee640fe
commit e34b04c8ca
1 changed files with 3 additions and 0 deletions

View File

@ -251,12 +251,14 @@ class FileTailer(object):
self.path = path
self.buf = b""
self.finished = finished
self.caughtup = False
self.more_content = asyncio.Event()
async def __aiter__(self):
with open(self.path, "rb") as fh:
while True:
if not self.finished and self.head >= self.tail:
self.caughtup = True
await self.more_content.wait()
self.more_content.clear()
self.tail = fh.seek(0, os.SEEK_END)
@ -322,6 +324,7 @@ class LogFile(FileTailer):
self.state = "replaying"
record_offset = self.offset
async for line_offset, line_size, line in self:
self.state = "watching" if self.caughtup else "replaying"
assert "\n" not in line
try:
reason = "unicode-encoding"