[Buildbot-commits] buildbot/buildbot/status builder.py,1.41,1.42

Brian Warner warner at users.sourceforge.net
Thu Nov 11 20:47:17 UTC 2004


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9956/buildbot/status

Modified Files:
	builder.py 
Log Message:
* buildbot/status/builder.py (LogFile.addEntry): smarter way to do it: one
string merge per chunk. There are now separate .entries and .runEntries
lists: when enumerating over all chunks, make sure to look at both.
* buildbot/test/test_status.py (Log): more tests


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- builder.py	11 Nov 2004 19:31:15 -0000	1.41
+++ builder.py	11 Nov 2004 20:47:15 -0000	1.42
@@ -77,12 +77,15 @@
     finished = False
     length = 0
     progress = None
+    chunkSize = 10*1000
+    runLength = 0
 
     def __init__(self, parent):
         self.step = parent
         self.watchers = []
         self.finishedWatchers = []
         self.entries = []
+        self.runEntries = []
 
     def getName(self):
         return self.name # set in BuildStepStatus.addLog
@@ -101,16 +104,17 @@
         return d
 
     def getText(self):
-        return "".join([e[1] for e in self.entries if e[0] in (STDOUT,STDERR)])
+        return "".join([e[1] for e in self.entries + self.runEntries
+                        if e[0] in (STDOUT,STDERR)])
     def getTextWithHeaders(self):
-        return "".join([e[1] for e in self.entries])
+        return "".join([e[1] for e in self.entries + self.runEntries])
     def getChunks(self):
-        return self.entries
+        return self.entries + self.runEntries
 
     def subscribe(self, receiver, catchup):
         self.watchers.append(receiver)
         if catchup:
-            for channel, text in self.entries:
+            for channel, text in self.entries + self.runEntries:
                 # TODO: add logChunks(), to send over everything at once?
                 receiver.logChunk(self.step.build, self.step, self,
                                   channel, text)
@@ -123,17 +127,28 @@
         self.progress = progress
         self.progressName = name
 
+    def merge(self):
+        # merge all .runEntries (which are all of the same type) into a
+        # single chunk for .entries
+        if not self.runEntries:
+            return
+        channel = self.runEntries[0][0]
+        text = "".join([c[1] for c in self.runEntries])
+        self.entries.append((channel, text))
+        self.runEntries = []
+        self.runLength = 0
+
     def addEntry(self, channel, text):
         assert not self.finished
-        if (self.entries
-            and channel == self.entries[-1][0]
-            and len(self.entries[-1][1]) < 10000):
-            # merge same-category chunks together, up to 10kb each, to cut
-            # down on overhead when assembling these into a single big string
-            # later.
-            self.entries[-1] = (channel, self.entries[-1][1] + text)
-        else:
-            self.entries.append((channel, text))
+        # we only add to .runEntries here. merge() is responsible for adding
+        # merged chunks to .entries
+        if self.runEntries and channel != self.runEntries[0][0]:
+            self.merge()
+        self.runEntries.append((channel, text))
+        self.runLength += len(text)
+        if self.runLength > self.chunkSize:
+            self.merge()
+
         for w in self.watchers:
             w.logChunk(self.step.build, self.step, self, channel, text)
         self.length += len(text)
@@ -148,6 +163,7 @@
         self.addEntry(HEADER, text)
 
     def finish(self):
+        self.merge()
         self.finished = True
         watchers = self.finishedWatchers
         self.finishedWatchers = []





More information about the Commits mailing list