From: Michael Tremer Date: Tue, 25 Jul 2023 14:02:52 +0000 (+0000) Subject: logstreams: Copy buffer before sending it off X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9f3ceedacd375773002e77503593e5d5ecc1453;p=pbs.git logstreams: Copy buffer before sending it off collections.deque() does not allow us to append new messages while we are reading from it. Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/logstreams.py b/src/buildservice/logstreams.py index 84b337e6..e5b37b80 100644 --- a/src/buildservice/logstreams.py +++ b/src/buildservice/logstreams.py @@ -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