]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
misc/cpu-watcher.tac: tolerate disk-full errors when writing the pickle, and pickle...
authorBrian Warner <warner@allmydata.com>
Fri, 5 Dec 2008 22:54:12 +0000 (15:54 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 5 Dec 2008 22:54:12 +0000 (15:54 -0700)
misc/cpu-watcher.tac

index 9695a69458fa74cc3a9b6937e44004a618db6c52..12f2932481f846c29ee7d03b1cba6673cb7498f2 100644 (file)
@@ -104,7 +104,7 @@ class CPUWatcher(service.MultiService, resource.Resource, Referenceable):
         resource.Resource.__init__(self)
         try:
             self.history = pickle.load(open("history.pickle", "rb"))
-        except EnvironmentError:
+        except:
             self.history = {}
         self.current = []
         self.observers = set()
@@ -199,8 +199,11 @@ 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.tmp", "wb"))
-        os.rename("history.pickle.tmp", "history.pickle")
+        try:
+            pickle.dump(self.history, open("history.pickle.tmp", "wb"))
+            os.rename("history.pickle.tmp", "history.pickle")
+        except:
+            pass
         for (pid, name) in processes:
             row = [name]
             for avg in self.AVERAGES: