)
class Jobs(base.Object):
- connections = {}
-
def init(self):
# Setup queue
self.queue = Queue(self.backend)
},
})
- def connected(self, connection):
- """
- Called when a builder has connected
- """
- # Replace any old connections
- if self.connection:
- log.warning("Closing connection to %s because it is being replaced" % self)
-
- # Close the previous connection
- self.connection.close(code=1000, reason="Replaced by a new connection")
-
- log.debug("Connection opened for %s" % self)
-
- # Store the connection
- self.backend.jobs.connections[self.uuid] = connection
-
- def disconnected(self):
- """
- Called when a builder has disconnected
- """
- log.debug("%s has disconnected" % self)
-
- try:
- del self.backend.jobs.connections[self.uuid]
- except IndexError:
- pass
-
- @property
- def connection(self):
- """
- Easy access to the control connection to a builder
- """
- try:
- return self.backend.jobs.connections[self.uuid]
- except KeyError:
- pass
-
async def finished(self, success, packages=None, message=None, logfile=None):
"""
Called when this job has finished