[Buildbot-commits] buildbot/buildbot/process builder.py,1.43,1.44

Brian Warner warner at users.sourceforge.net
Mon Jul 2 17:50:19 UTC 2007


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

Modified Files:
	builder.py 
Log Message:
[project @ choose slaves randomly rather than always picking the first one, closes #36]

Original author: warner at lothar.com
Date: 2007-07-02 17:49:12+00:00

Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/builder.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- builder.py	23 Jan 2007 08:01:45 -0000	1.43
+++ builder.py	2 Jul 2007 17:50:17 -0000	1.44
@@ -1,5 +1,5 @@
-#! /usr/bin/python
 
+import random
 from zope.interface import implements
 from twisted.python import log, components
 from twisted.spread import pb
@@ -224,6 +224,7 @@
 
     expectations = None # this is created the first time we get a good build
     START_BUILD_TIMEOUT = 10
+    CHOOSE_SLAVES_RANDOMLY = True # disabled for determinism during tests
 
     def __init__(self, setup, builder_status):
         """
@@ -502,15 +503,18 @@
         if not self.buildable:
             self.updateBigStatus()
             return # nothing to do
-        # find the first idle slave
-        for sb in self.slaves:
-            if sb.isAvailable():
-                break
-        else:
+
+        # pick an idle slave
+        available_slaves = [sb for sb in self.slaves if sb.isAvailable()]
+        if not available_slaves:
             log.msg("%s: want to start build, but we don't have a remote"
                     % self)
             self.updateBigStatus()
             return
+        if self.CHOOSE_SLAVES_RANDOMLY:
+            sb = random.choice(available_slaves)
+        else:
+            sb = available_slaves[0]
 
         # there is something to build, and there is a slave on which to build
         # it. Grab the oldest request, see if we can merge it with anything





More information about the Commits mailing list