From: Michael Tremer Date: Sat, 18 Jun 2022 11:53:47 +0000 (+0000) Subject: hub: Close any existing connections from builders X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c96812334aae65406ebc3e0337813157d669e6eb;p=pbs.git hub: Close any existing connections from builders This causes that a new connection will replace an older one. Signed-off-by: Michael Tremer --- diff --git a/src/hub/queue.py b/src/hub/queue.py index 68790898..169d587a 100644 --- a/src/hub/queue.py +++ b/src/hub/queue.py @@ -85,6 +85,17 @@ class QueueHandler(BackendMixin, HTTPBasicAuthMixin, tornado.websocket.WebSocket 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)