Skip to content

Commit

Permalink
Prune a builder's list of events whenever an event is added.
Browse files Browse the repository at this point in the history
This prevents the list of events from growing beyond the eventHorizon
limit if the builder is only run occasionally.
  • Loading branch information
Chris AtLee committed Jul 13, 2010
1 parent a0ca76e commit cb8dd62
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions master/buildbot/status/builder.py
Expand Up @@ -1714,12 +1714,15 @@ def getBuildByNumber(self, number):
except EOFError:
raise IndexError("corrupted build pickle %d" % number)

def prune(self):
gc.collect()

def prune(self, events_only=False):
# begin by pruning our own events
self.events = self.events[-self.eventHorizon:]

if events_only:
return

gc.collect()

# get the horizons straight
if self.buildHorizon:
earliest_build = self.nextBuildNumber - self.buildHorizon
Expand Down Expand Up @@ -1917,6 +1920,7 @@ def addEvent(self, text=[]):
e.started = util.now()
e.text = text
self.events.append(e)
self.prune(events_only=True)
return e # they are free to mangle it further

def addPointEvent(self, text=[]):
Expand All @@ -1927,6 +1931,7 @@ def addPointEvent(self, text=[]):
e.finished = 0
e.text = text
self.events.append(e)
self.prune(events_only=True)
return e # for consistency, but they really shouldn't touch it

def setBigState(self, state):
Expand Down

0 comments on commit cb8dd62

Please sign in to comment.