[Buildbot-devel] Exclusive access mode patch for Locks

A.T.Hofkamp a.t.hofkamp at tue.nl
Mon Jul 7 07:59:56 UTC 2008


Hello all,

I have just submitted a patch for claiming a lock exclusively, even if the 
maxCount > 1.
For details and the actual patch, see #313 in Trac.

At user-side, the changes are very small, only an addition of specifying the 
mode of accessing when using a lock. Example:


     In the next example, a limit of at most two builds is enforced. The
     cleanup process however needs exclusive access to prevent interference
     with the build processes.


     from buildbot import locks
     from buildbot.steps import source, shell
     from buildbot.process import factory

     build_lock = locks.MasterLock("builds", maxCount=2)
     fb = factory.BuildFactory()
     fb.addStep(source.SVN(svnurl="http://example.org/svn/Trunk"))
     fb.addStep(shell.ShellCommand(command=["make", "all"]))
     b1 = {'name': 'b1', 'slavename': 'bot-1', 'builddir' : 'b1',
           'factory': fb, 'locks': [build_lock.access('counting')] }
     b2 = {'name': 'b2', 'slavename': 'bot-2', 'builddir' : 'b2',
           'factory': fb, 'locks': [build_lock.access('counting')] }
     b3 = {'name': 'b3', 'slavename': 'bot-3', 'builddir' : 'b3',
           'factory': fb, 'locks': [build_lock.access('counting')] }
     fc = factory.BuildFactory()
     fc.addStep(shell.ShellCommand(command=["cleanup"]))
     cl = {'name': 'clean', 'slavename': 'bot-1', 'builddir' :clean',
           'factory': fc, 'locks': [build_lock.access('exclusive')] }
     c['builders'] = [b1, b2, b3, cl]

Note the addition of ".access(MODE)" while using the lock.

For a MasterLock, 'exclusive' mode means one user for the entire master, with 
a SlaveLock it means one user for each slave.


For backwards compability, the addition is optional. If you don't specify it, 
it defaults to 'counting' mode, which is current behavior.


Albert





More information about the devel mailing list