misc/cpu-watcher.tac: use writeaside-and-rename for the history.pickle file
authorBrian Warner <warner@allmydata.com>
Wed, 1 Oct 2008 00:30:53 +0000 (17:30 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 1 Oct 2008 00:30:53 +0000 (17:30 -0700)
misc/cpu-watcher.tac

index da8d29abedaae08b0e7c6db5ded1e2926b05bd85..9695a69458fa74cc3a9b6937e44004a618db6c52 100644 (file)
@@ -199,7 +199,8 @@ class CPUWatcher(service.MultiService, resource.Resource, Referenceable):
             except:
                 log.msg("error reading process %s (%s), ignoring" % (pid, name))
                 log.err()
-        pickle.dump(self.history, open("history.pickle", "wb"))
+        pickle.dump(self.history, open("history.pickle.tmp", "wb"))
+        os.rename("history.pickle.tmp", "history.pickle")
         for (pid, name) in processes:
             row = [name]
             for avg in self.AVERAGES: