[Buildbot-devel] Builder status files

Dobes Vandermeer dobesv at gmail.com
Thu Sep 29 17:53:30 UTC 2005


It seems that the builder status pickles are not saving/loading on
windows, currently.

I fixed this by ensuring the the file is closed after saving the
pickle; I suspect that somehow the I/O buffers were not flushed to
disk before the temp file was renamed to the final filename.  I also
changed the read/write modes from "r"/"w" to "rb"/"wb" because I think
these files are binary when protocol -1 is used.  Actually, I don't
know which of these changes fixed it...

Index: status/builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.66
diff -u -r1.66 builder.py
--- status/builder.py	31 Aug 2005 02:26:34 -0000	1.66
+++ status/builder.py	29 Sep 2005 17:42:26 -0000
@@ -1228,10 +1228,13 @@
         filename = os.path.join(self.builder.basedir, "%d" % self.number)
         if os.path.isdir(filename):
             # leftover from 0.5.0, which stored builds in directories
-            shutils.rmtree(filename, ignore_errors=True)
+            shutil.rmtree(filename, ignore_errors=True)
         tmpfilename = filename + ".tmp"
         try:
-            pickle.dump(self, open(tmpfilename, "w"), -1)
+            print 'Dumping pickle to', tmpfilename, 'and renaming to', filename
+            fd = open(tmpfilename, "wb")
+            pickle.dump(self, fd, -1)
+            fd.close()
             if sys.platform == 'win32':
                 # windows cannot rename a file on top of an existing one, so
                 # fall back to delete-first. There are ways this can fail and
@@ -1333,7 +1336,10 @@
         filename = os.path.join(self.basedir, "builder")
         tmpfilename = filename + ".tmp"
         try:
-            pickle.dump(self, open(tmpfilename, "w"), -1)
+            print 'Dumping', self, 'to', filename
+            fd = open(tmpfilename, "wb")
+            pickle.dump(self, fd, -1)
+            fd.close()
             if sys.platform == 'win32':
                 # windows cannot rename a file on top of an existing one
                 if os.path.exists(filename):
@@ -1361,7 +1367,7 @@
                 return build
         filename = os.path.join(self.basedir, "%d" % number)
         try:
-            build = pickle.load(open(filename, "r"))
+            build = pickle.load(open(filename, "rb"))
             build.builder = self
             # handle LogFiles from after 0.5.0 and before 0.6.5
             build.upgradeLogfiles()
@@ -1740,11 +1746,14 @@
         log.msg("trying to load status pickle from %s" % filename)
         builder_status = None
         try:
-            builder_status = pickle.load(open(filename, "r"))
+            builder_status = pickle.load(open(filename, "rb"))
         except IOError:
             log.msg("no saved status pickle, creating a new one")
         except:
             log.msg("error while loading status pickle, creating a new one")
+            import traceback
+            traceback.print_exc()
+
         if not builder_status:
             builder_status = BuilderStatus(name, category)
             builder_status.addPointEvent(["builder", "created"])




More information about the devel mailing list