misc/cpu-watcher.tac: use writeaside-and-rename for the history.pickle file

This commit is contained in:
Brian Warner 2008-09-30 17:30:53 -07:00
parent 3aba70bbcf
commit 06770f720e

View 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: