[Buildbot-commits] buildbot/buildbot buildslave.py,1.3,1.4

Brian Warner warner at users.sourceforge.net
Tue Aug 7 23:41:08 UTC 2007


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

Modified Files:
	buildslave.py 
Log Message:
[project @ add max_builds= to BuildSlave, thanks to Dustin Mitchell. Closes #48.]

Original author: warner at lothar.com
Date: 2007-08-07 23:40:12+00:00

Index: buildslave.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/buildslave.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- buildslave.py	7 Aug 2007 20:23:39 -0000	1.3
+++ buildslave.py	7 Aug 2007 23:41:05 -0000	1.4
@@ -16,7 +16,16 @@
     running builds.  I am instantiated by the configuration file, and can be
     subclassed to add extra functionality."""
 
-    def __init__(self, name, password):
+    def __init__(self, name, password, max_builds=None):
+        """
+        @param name: botname this machine will supply when it connects
+        @param password: password this machine will supply when
+                         it connects
+        @param max_builds: maximum number of simultaneous builds that will
+                           be run concurrently on this buildslave (the
+                           default is None for no limit)
+        """
+
         self.slavename = name
         self.password = password
         self.botmaster = None # no buildmaster yet
@@ -24,6 +33,7 @@
         self.slave = None # a RemoteReference to the Bot, when connected
         self.slave_commands = None
         self.slavebuilders = []
+        self.max_builds = max_builds
 
     def update(self, new):
         """
@@ -33,7 +43,9 @@
         """
         # the reconfiguration logic should guarantee this:
         assert self.slavename == new.slavename
-        self.password = new.password
+        assert self.password == new.password
+        assert self.__class__ == new.__class__
+        self.max_builds = new.max_builds
 
     def __repr__(self):
         builders = self.botmaster.getBuildersForSlave(self.slavename)
@@ -237,5 +249,9 @@
         can start a build.  This function can be used to limit overall
         concurrency on the buildslave.
         """
+        if self.max_builds:
+            active_builders = [sb for sb in self.slavebuilders if sb.isBusy()]
+            if len(active_builders) >= self.max_builds:
+                return False
         return True
 





More information about the Commits mailing list