From: Michael Tremer Date: Wed, 13 Sep 2023 17:44:43 +0000 (+0000) Subject: logstream: Fix sending the last messages X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b25b559f1a440c2686560278761068488fc158e;p=pbs.git logstream: Fix sending the last messages Instead, the first messages in the buffer were sent. Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/logstreams.py b/src/buildservice/logstreams.py index 551f83bb..44f790f9 100644 --- a/src/buildservice/logstreams.py +++ b/src/buildservice/logstreams.py @@ -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): """