]> git.ipfire.org Git - pbs.git/commitdiff
logstream: Fix sending the last messages
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Sep 2023 17:44:43 +0000 (17:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Sep 2023 17:44:43 +0000 (17:44 +0000)
Instead, the first messages in the buffer were sent.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/logstreams.py

index 551f83bb7f4da8c2ec09257c6060dba2b9b5aaa4..44f790f9e51b79ccb824cb300baa4b128adf0575 100644 (file)
@@ -107,17 +107,15 @@ class LogStream(base.Object):
                # Store a reference to the consumer
                self.consumers.append(consumer)
 
-               # Send all messages in the buffer
-               async with self._lock:
-                       for i, message in enumerate(self.buffer):
-                               # Only sent up to limit messages
-                               if limit and i >= limit:
-                                       break
+               log.debug("%s has joined the stream for %s" % (consumer, self.job))
 
-                               # Send the message
-                               await consumer.message(message)
+               # Select all messages we want to send
+               async with self._lock:
+                       buffer = collections.deque(self.buffer, limit)
 
-               log.debug("%s has joined the stream for %s" % (consumer, self.job))
+               # Send all messages
+               for message in buffer:
+                       await consumer.message(message)
 
        def leave(self, consumer):
                """