This causes that a new connection will replace an older one.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
def open(self):
log.debug("Connection opened by %s" % self.builder)
+ # Find any previous connections of this builder and close them
+ for connection in connections:
+ if not connection.builder == self.builder:
+ continue
+
+ log.warning("Closing connection to builder %s because it is being replaced" \
+ % self.builder)
+
+ # Close the previous connection
+ connection.close(code=1000, reason="Replaced by a new connection")
+
# Add this connection to the list
connections.append(self)