[Buildbot-commits] buildbot/buildbot/process builder.py,1.52,1.53

Brian Warner warner at users.sourceforge.net
Sun Mar 23 03:14:49 UTC 2008


Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3555/buildbot/process

Modified Files:
	builder.py 
Log Message:
[project @ builder: make it possible to stop builds after a Builder-changing reconfig. Closes #22.]

Original author: warner at lothar.com
Date: 2008-03-23 03:11:09+00:00

Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/builder.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- builder.py	18 Mar 2008 22:25:55 -0000	1.52
+++ builder.py	23 Mar 2008 03:14:47 -0000	1.53
@@ -1,5 +1,5 @@
 
-import random
+import random, weakref
 from zope.interface import implements
 from twisted.python import log, components
 from twisted.spread import pb
@@ -284,6 +284,8 @@
         # build/wannabuild slots: Build objects move along this sequence
         self.buildable = []
         self.building = []
+        # old_building holds active builds that were stolen from a predecessor
+        self.old_building = weakref.WeakKeyDictionary()
 
         # buildslaves which have connected but which are not yet available.
         # These are always in the ATTACHING state.
@@ -376,13 +378,21 @@
         self.buildable.extend(old.buildable)
         old.buildable = []
 
-        # old.building is not migrated: it keeps track of builds which were
-        # in progress in the old Builder. When those builds finish, the old
-        # Builder will be notified, not us. However, since the old
-        # SlaveBuilder will point to us, it is our maybeStartBuild() that
-        # will be triggered.
+        # old.building (i.e. builds which are still running) is not migrated
+        # directly: it keeps track of builds which were in progress in the
+        # old Builder. When those builds finish, the old Builder will be
+        # notified, not us. However, since the old SlaveBuilder will point to
+        # us, it is our maybeStartBuild() that will be triggered.
         if old.building:
             self.builder_status.setBigState("building")
+        # however, we do grab a weakref to the active builds, so that our
+        # BuilderControl can see them and stop them. We use a weakref because
+        # we aren't the one to get notified, so there isn't a convenient
+        # place to remove it from self.building .
+        for b in old.building:
+            self.old_building[b] = None
+        for b in old.old_building:
+            self.old_building[b] = None
 
         # Our set of slavenames may be different. Steal any of the old
         # buildslaves that we want to keep using.
@@ -414,6 +424,15 @@
 
         return # all done
 
+    def getBuild(self, number):
+        for b in self.building:
+            if b.build_status.number == number:
+                return b
+        for b in self.old_building.keys():
+            if b.build_status.number == number:
+                return b
+        return None
+
     def fireTestEvent(self, name, fire_with=None):
         if fire_with is None:
             fire_with = self
@@ -701,10 +720,7 @@
         raise NotImplementedError
 
     def getBuild(self, number):
-        for b in self.original.building:
-            if b.build_status.number == number:
-                return b
-        return None
+        return self.original.getBuild(number)
 
     def ping(self, timeout=30):
         if not self.original.slaves:





More information about the Commits mailing list