From 06770f720e45a5b4d4a9049a8f73630e5c511e98 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Tue, 30 Sep 2008 17:30:53 -0700
Subject: [PATCH] misc/cpu-watcher.tac: use writeaside-and-rename for the
 history.pickle file

---
 misc/cpu-watcher.tac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/misc/cpu-watcher.tac b/misc/cpu-watcher.tac
index da8d29ab..9695a694 100644
--- a/misc/cpu-watcher.tac
+++ b/misc/cpu-watcher.tac
@@ -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:
-- 
2.45.2