Skip to content

Instantly share code, notes, and snippets.

@rail
Created January 20, 2012 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rail/1647790 to your computer and use it in GitHub Desktop.
Save rail/1647790 to your computer and use it in GitHub Desktop.
diff --git a/scheduler.py b/scheduler.py
index d109a9d..76242ce 100644
--- a/scheduler.py
+++ b/scheduler.py
@@ -379,33 +379,33 @@ class AggregatingScheduler(BaseScheduler, Triggerable):
for b in list(state['remainingBuilders']):
if b not in self.upstreamBuilders:
state['remainingBuilders'].remove(b)
# Add new upstream builders
for b in self.upstreamBuilders:
if b not in state['remainingBuilders']:
state['remainingBuilders'].append(b)
log.msg('%s <id=%s>: reloaded' % (self.__class__.__name__,
- self.schedulerid))
+ id(self)))
if old_state != state:
log.msg('%s <id=%s>: old state: %s' % (self.__class__.__name__,
- self.schedulerid, old_state))
+ id(self), old_state))
log.msg('%s <id=%s>: new state: %s' % (self.__class__.__name__,
- self.schedulerid, state))
+ id(self), state))
self.set_state(t, state)
def trigger(self, ss, set_props=None):
"""Reset scheduler state"""
self.parent.db.runInteractionNow(self._trigger)
def _trigger(self, t):
state = self.get_initial_state(None)
state['lastReset'] = state['lastCheck']
log.msg('%s <id=%s>: reset state: %s' % (self.__class__.__name__,
- self.schedulerid, state))
+ id(self), state))
self.set_state(t, state)
def run(self):
d = self.parent.db.runInteraction(self._run)
return d
def findNewBuilds(self, db, t, lastCheck):
q = """SELECT buildername, sourcestampid FROM
@@ -422,19 +422,25 @@ class AggregatingScheduler(BaseScheduler, Triggerable):
q = db.quoteq(q)
t.execute(q, tuple(self.upstreamBuilders) + tuple(self.okResults) +
(lastCheck,))
return t.fetchall()
def _run(self, t):
if self.working:
log.msg('%s <id=%s>: another instance is still running, skipping.' \
- % (self.__class__.__name__, self.schedulerid))
+ % (self.__class__.__name__, id(self)))
return
self.working = True
+ try:
+ self.processRequest(t)
+ finally:
+ self.working = False
+
+ def processRequest(self, t):
db = self.parent.db
state = self.get_state(t)
# Check for new builds completed since lastCheck
lastCheck = state['lastCheck']
remainingBuilders = state['remainingBuilders']
n = now()
newBuilds = self.findNewBuilds(db, t, lastCheck)
@@ -448,25 +454,24 @@ class AggregatingScheduler(BaseScheduler, Triggerable):
state['remainingBuilders'] = remainingBuilders
else:
ss = SourceStamp(branch=self.branch)
ssid = db.get_sourcestampid(ss, t)
# Start a build!
log.msg(
'%s <id=%s>: new buildset: name=%s, branch=%s, ssid=%s, builders: %s' \
- % (self.__class__.__name__, self.schedulerid, self.name,
+ % (self.__class__.__name__, id(self), self.name,
self.branch, ssid, ', '.join(self.builderNames)))
self.create_buildset(ssid, "downstream", t)
# Reset the list of builders we're waiting for
state = self.get_initial_state(None)
self.set_state(t, state)
- self.working = False
def makePropertiesScheduler(base_class, propfuncs, *args, **kw):
"""Return a subclass of `base_class` that will call each of `propfuncs` to
generate a set of properties to attach to new buildsets.
Each function of propfuncs will be passed (scheduler instance, db
transaction, sourcestamp id) and must return a Properties instance. These
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment