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>
# 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