Ticket #313: harmless2.patch
| File harmless2.patch, 9.5 kB (added by albertHofkamp, 6 months ago) |
|---|
-
buildbot-0.7.7/buildbot/locks.py
old new 10 10 debuglog = lambda m: None 11 11 12 12 class BaseLock: 13 """ 14 Class handling claiming and releasing of L{self}, and keeping track of 15 current and waiting owners. 16 17 @note: Ideally, we'd like to maintain FIFO order. The place to do that 18 would be the L{isAvailable()} function. However, this function is 19 called by builds/steps both for the first time, and after waking 20 them up by L{self} from the L{self.waiting} queue. There is 21 currently no way of distinguishing between them. 22 """ 13 23 description = "<BaseLock>" 14 24 15 25 def __init__(self, name, maxCount=1): … … 22 32 return self.description 23 33 24 34 def isAvailable(self): 35 """ Return a boolean whether the lock is available for claiming """ 25 36 debuglog("%s isAvailable: self.owners=%r" % (self, self.owners)) 26 37 return len(self.owners) < self.maxCount 27 38 28 39 def claim(self, owner): 40 """ Claim the lock (lock must be available) """ 29 41 debuglog("%s claim(%s)" % (self, owner)) 30 42 assert owner is not None 31 43 assert len(self.owners) < self.maxCount, "ask for isAvailable() first" … … 33 45 debuglog(" %s is claimed" % (self,)) 34 46 35 47 def release(self, owner): 48 """ Release the lock """ 36 49 debuglog("%s release(%s)" % (self, owner)) 37 50 assert owner in self.owners 38 51 self.owners.remove(owner) … … 90 103 return self.locks[slavename] 91 104 92 105 106 class BaseLockId(util.ComparableMixin): 107 """ Abstract base class for LockId classes. 108 109 Derived classes should add 110 - Comparison with the L{util.ComparableMixin} via the L{compare_attrs} 111 class variable. 112 - Link to the actual lock class should be added with the L{lockClass} 113 class variable. 114 """ 115 93 116 # master.cfg should only reference the following MasterLock and SlaveLock 94 117 # classes. They are identifiers that will be turned into real Locks later, 95 118 # via the BotMaster.getLockByID method. 96 119 97 class MasterLock( util.ComparableMixin):120 class MasterLock(BaseLockId): 98 121 """I am a semaphore that limits the number of simultaneous actions. 99 122 100 123 Builds and BuildSteps can declare that they wish to claim me as they run. … … 113 136 self.name = name 114 137 self.maxCount = maxCount 115 138 116 class SlaveLock( util.ComparableMixin):139 class SlaveLock(BaseLockId): 117 140 """I am a semaphore that limits simultaneous actions on each buildslave. 118 141 119 142 Builds and BuildSteps can declare that they wish to claim me as they run. -
buildbot-0.7.7/buildbot/master.py
old new 26 26 from buildbot.changes.changes import Change, ChangeMaster 27 27 from buildbot.sourcestamp import SourceStamp 28 28 from buildbot.buildslave import BuildSlave 29 from buildbot import interfaces 29 from buildbot import interfaces, locks 30 30 31 31 ######################################## 32 32 … … 209 209 @param lockid: a locks.MasterLock or locks.SlaveLock instance 210 210 @return: a locks.RealMasterLock or locks.RealSlaveLock instance 211 211 """ 212 assert isinstance(lockid, (locks.MasterLock, locks.SlaveLock)) 212 213 if not lockid in self.locks: 213 214 self.locks[lockid] = lockid.lockClass(lockid) 214 215 # if the master.cfg file has changed maxCount= on the lock, the next … … 629 630 630 631 # assert that all locks used by the Builds and their Steps are 631 632 # uniquely named. 632 lock s= {}633 lock_dict = {} 633 634 for b in builders: 634 635 for l in b.get('locks', []): 635 if lock s.has_key(l.name):636 if lock s[l.name] is not l:636 if lock_dict.has_key(l.name): 637 if lock_dict[l.name] is not l: 637 638 raise ValueError("Two different locks (%s and %s) " 638 639 "share the name %s" 639 % (l, lock s[l.name], l.name))640 % (l, lock_dict[l.name], l.name)) 640 641 else: 641 lock s[l.name] = l642 lock_dict[l.name] = l 642 643 # TODO: this will break with any BuildFactory that doesn't use a 643 644 # .steps list, but I think the verification step is more 644 645 # important. 645 646 for s in b['factory'].steps: 646 647 for l in s[1].get('locks', []): 647 if lock s.has_key(l.name):648 if lock s[l.name] is not l:648 if lock_dict.has_key(l.name): 649 if lock_dict[l.name] is not l: 649 650 raise ValueError("Two different locks (%s and %s)" 650 651 " share the name %s" 651 % (l, lock s[l.name], l.name))652 % (l, lock_dict[l.name], l.name)) 652 653 else: 653 lock s[l.name] = l654 lock_dict[l.name] = l 654 655 655 656 # slavePortnum supposed to be a strports specification 656 657 if type(slavePortnum) is int: -
buildbot-0.7.7/buildbot/util.py
old new 60 60 return hash(tuple(alist)) 61 61 62 62 def __cmp__(self, them): 63 if cmp(type(self), type(them)): 64 return cmp(type(self), type(them)) 65 if cmp(self.__class__, them.__class__): 66 return cmp(self.__class__, them.__class__) 63 result = cmp(type(self), type(them)) 64 if result: 65 return result 66 67 result = cmp(self.__class__, them.__class__) 68 if result: 69 return result 70 67 71 assert self.compare_attrs == them.compare_attrs 68 72 self_list= [getattr(self, name, _None) for name in self.compare_attrs] 69 73 them_list= [getattr(them, name, _None) for name in self.compare_attrs] -
buildbot-0.7.7/docs/buildbot.texinfo
old new 5443 5443 simultaneous builds as there are machines. 5444 5444 5445 5445 Each @code{Lock} is created with a unique name. Each lock gets a count 5446 of how many owners it may have: how many processes can claim it at th s5446 of how many owners it may have: how many processes can claim it at the 5447 5447 same time. This limit defaults to one, and is controllable through the 5448 5448 @code{maxCount} argument. On @code{SlaveLock}s you can set the owner 5449 5449 count on a per-slave basis by providing a dictionary (that maps from … … 5493 5493 f.addStep(source.SVN(svnurl="http://example.org/svn/Trunk")) 5494 5494 f.addStep(shell.ShellCommand(command="make all")) 5495 5495 f.addStep(shell.ShellCommand(command="make test", locks=[db_lock])) 5496 b1 = @{'name': 'full1', 'slavename': 'bot-1', builddir='f1', 'factory': f@}5497 b2 = @{'name': 'full2', 'slavename': 'bot-2', builddir='f2', 'factory': f@}5498 b3 = @{'name': 'full3', 'slavename': 'bot-3', builddir='f3', 'factory': f@}5496 b1 = @{'name': 'full1', 'slavename': 'bot-1', 'builddir': 'f1', 'factory': f@} 5497 b2 = @{'name': 'full2', 'slavename': 'bot-2', 'builddir': 'f2', 'factory': f@} 5498 b3 = @{'name': 'full3', 'slavename': 'bot-3', 'builddir': 'f3', 'factory': f@} 5499 5499 c['builders'] = [b1, b2, b3] 5500 5500 @end example 5501 5501 … … 5522 5522 f22 = factory.Trial(source, trialpython=["python2.2"]) 5523 5523 f23 = factory.Trial(source, trialpython=["python2.3"]) 5524 5524 f24 = factory.Trial(source, trialpython=["python2.4"]) 5525 b1 = @{'name': 'p22', 'slavename': 'bot-1', builddir='p22', 'factory': f22,5526 ' locks': [slow_lock] @}5527 b2 = @{'name': 'p23', 'slavename': 'bot-1', builddir='p23', 'factory': f23,5528 ' locks': [slow_lock] @}5529 b3 = @{'name': 'p24', 'slavename': 'bot-1', builddir='p24', 'factory': f24,5530 ' locks': [slow_lock] @}5525 b1 = @{'name': 'p22', 'slavename': 'bot-1', 'builddir': 'p22', 5526 'factory': f22, 'locks': [slow_lock] @} 5527 b2 = @{'name': 'p23', 'slavename': 'bot-1', 'builddir': 'p23', 5528 'factory': f23, 'locks': [slow_lock] @} 5529 b3 = @{'name': 'p24', 'slavename': 'bot-1', 'builddir': 'p24', 5530 'factory': f24, 'locks': [slow_lock] @} 5531 5531 c['builders'] = [b1, b2, b3] 5532 5532 @end example 5533 5533 … … 5555 5555 f.addStep(shell.ShellCommand(command="make test", locks=[cpu_lock])) 5556 5556 f.addStep(shell.ShellCommand(command="make db-test", locks=[db_lock, cpu_lock])) 5557 5557 5558 b1 = @{'name': 'full1', 'slavename': 'bot-slow', builddir='full1',5559 'factory': f@} 5560 b2 = @{'name': 'full2', 'slavename': 'bot-slow', builddir='full2',5561 'factory': f@} 5562 b3 = @{'name': 'full3', 'slavename': 'bot-fast', builddir='full3',5563 'factory': f@} 5564 b4 = @{'name': 'full4', 'slavename': 'bot-fast', builddir='full4',5558 b1 = @{'name': 'full1', 'slavename': 'bot-slow', 'builddir': 'full1', 5559 'factory': f@} 5560 b2 = @{'name': 'full2', 'slavename': 'bot-slow', 'builddir': 'full2', 5561 'factory': f@} 5562 b3 = @{'name': 'full3', 'slavename': 'bot-fast', 'builddir': 'full3', 5563 'factory': f@} 5564 b4 = @{'name': 'full4', 'slavename': 'bot-fast', 'builddir': 'full4', 5565 5565 'factory': f@} 5566 5566 c['builders'] = [b1, b2, b3, b4] 5567 5567 @end example … … 6529 6529 6530 6530 @example 6531 6531 from buildbot.status import html 6532 w = html.W aterfall(http_port=8080)6532 w = html.WebStatus(http_port=8080) 6533 6533 c['status'].append(w) 6534 6534 @end example 6535 6535
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)