]> git.ipfire.org Git - pbs.git/commitdiff
logstreams: Copy buffer before sending it off
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Jul 2023 14:02:52 +0000 (14:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Jul 2023 14:02:52 +0000 (14:02 +0000)
collections.deque() does not allow us to append new messages while we
are reading from it.

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

index 84b337e67a86129073a357cc54d0c8c70c74e032..e5b37b80d8eb398c44de1c05d1395ef4a3e94887 100644 (file)
@@ -104,8 +104,12 @@ class LogStream(base.Object):
                # Store a reference to the consumer
                self.consumers.append(consumer)
 
+               # Create a (shallow) copy of the buffer
+               # to avoid changes to the original one while this is running.
+               buffer = self.buffer.copy()
+
                # Send all messages in the buffer
-               for i, message in enumerate(self.buffer):
+               for i, message in enumerate(buffer):
                        # Only sent up to limit messages
                        if limit and i >= limit:
                                break