From e34b04c8ca939425b48fdefbf79edb4b70e479a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Mon, 7 Nov 2022 22:22:31 +0200 Subject: [PATCH] Fix state reporting --- log_shipper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/log_shipper.py b/log_shipper.py index bc6e904..af0f882 100755 --- a/log_shipper.py +++ b/log_shipper.py @@ -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"