Permalink
Browse files

(refs #35) fix dependent scheduler re-checking: make calculation of u…

…pstream lazier
  • Loading branch information...
1 parent 0c97e6e commit 4066acfdd6477e59b00767c1c5607e4666e15d6d Dustin J. Mitchell committed Jul 3, 2009
Showing with 16 additions and 6 deletions.
  1. +16 −6 buildbot/scheduler.py
View
@@ -319,40 +319,50 @@ class Dependent(BaseUpstreamScheduler):
def __init__(self, name, upstream, builderNames, properties={}):
assert interfaces.IUpstreamScheduler.providedBy(upstream)
BaseUpstreamScheduler.__init__(self, name, properties)
- self.upstream = upstream
+ self.upstream_name = upstream.name
+ self.upstream = None
self.builderNames = builderNames
def listBuilderNames(self):
return self.builderNames
def getPendingBuildTimes(self):
# report the upstream's value
- return self.upstream.getPendingBuildTimes()
+ return self.getUpstreamScheduler().getPendingBuildTimes()
def startService(self):
service.MultiService.startService(self)
+ self.upstream = self.findUpstreamScheduler()
self.upstream.subscribeToSuccessfulBuilds(self.upstreamBuilt)
def stopService(self):
d = service.MultiService.stopService(self)
self.upstream.unsubscribeToSuccessfulBuilds(self.upstreamBuilt)
+ self.upstream = None
return d
def upstreamBuilt(self, ss):
bs = buildset.BuildSet(self.builderNames, ss,
properties=self.properties)
self.submitBuildSet(bs)
- def checkUpstreamScheduler(self):
+ def findUpstreamScheduler(self):
# find our *active* upstream scheduler (which may not be self.upstream!) by name
- up_name = self.upstream.name
upstream = None
for s in self.parent.allSchedulers():
- if s.name == up_name and interfaces.IUpstreamScheduler.providedBy(s):
+ if s.name == self.upstream_name and interfaces.IUpstreamScheduler.providedBy(s):
upstream = s
if not upstream:
log.msg("ERROR: Couldn't find upstream scheduler of name <%s>" %
- up_name)
+ self.upstream_name)
+ return upstream
+
+ def checkUpstreamScheduler(self):
+ # if we don't already have an upstream, then there's nothing to worry about
+ if not self.upstream:
+ return
+
+ upstream = self.findUpstreamScheduler()
# if it's already correct, we're good to go
if upstream is self.upstream:

0 comments on commit 4066acf

Please sign in to comment.