[Buildbot-devel] Dynamic master lock per change request

Vitali Lovich vlovich at gmail.com
Fri Oct 17 03:50:24 UTC 2014


Hi,

I’m wondering if anyone has any ideas on how to dynamically adjust the set of locks
needed for a build on a per change-request basis.

The context is that the master lock that gets acquired depends on the codebase that a
builder is building (I can have n independent projects using the builder, but the builder
can only process 1 build per project at a time).

I’m currently looking at over-riding the Build.startBuild method in my own DynamicBuild class
& simply adjusting self.locks before calling the real startBuild.

Something like:

class DynamicBuild(Build):
    _masterLocks = {}

    @staticmethod
    def find_or_create_master_lock_for_repository(repository):
        lock = DynamicBuild._masterLocks.get(repository)
            if lock is None:
                lock = locks.MasterLock(repository + ‘ submission')
                _masterLocks[repository] = lock
            return lock

    def startBuild(self, build_status, expectations, slavebuilder):
        lock = DynamicBuild.find_or_create_master_lock_for_repository(build_status.getProperty(‘repository’))
        self.locks.append(lock)
        return Build.startBuild(self, build_status, expectations, slavebuilder)

Does that seam like a workable idea?

Is there a better approach?  I’m also thinking of overriding the BuildFactory so that I could
keep the set of master locks (custom because I would need the BuildFactory to give the Build
an instance of itself). 

Thanks,
Vitali



More information about the devel mailing list