]> git.ipfire.org Git - pbs.git/commitdiff
hub: Close any existing connections from builders
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 18 Jun 2022 11:53:47 +0000 (11:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 18 Jun 2022 11:53:47 +0000 (11:53 +0000)
This causes that a new connection will replace an older one.

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

index 6879089852f334a4dcf868a416cb457bddd255e5..169d587a32af3d60e0903643d0d808884d82bd37 100644 (file)
@@ -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)