misc/cpu-watcher.tac: tolerate disk-full errors when writing the pickle, and pickle corruption from earlier disk-full errors
This commit is contained in:
parent
21d88a0cba
commit
6ec352fe92
|
@ -104,7 +104,7 @@ class CPUWatcher(service.MultiService, resource.Resource, Referenceable):
|
||||||
resource.Resource.__init__(self)
|
resource.Resource.__init__(self)
|
||||||
try:
|
try:
|
||||||
self.history = pickle.load(open("history.pickle", "rb"))
|
self.history = pickle.load(open("history.pickle", "rb"))
|
||||||
except EnvironmentError:
|
except:
|
||||||
self.history = {}
|
self.history = {}
|
||||||
self.current = []
|
self.current = []
|
||||||
self.observers = set()
|
self.observers = set()
|
||||||
|
@ -199,8 +199,11 @@ class CPUWatcher(service.MultiService, resource.Resource, Referenceable):
|
||||||
except:
|
except:
|
||||||
log.msg("error reading process %s (%s), ignoring" % (pid, name))
|
log.msg("error reading process %s (%s), ignoring" % (pid, name))
|
||||||
log.err()
|
log.err()
|
||||||
pickle.dump(self.history, open("history.pickle.tmp", "wb"))
|
try:
|
||||||
os.rename("history.pickle.tmp", "history.pickle")
|
pickle.dump(self.history, open("history.pickle.tmp", "wb"))
|
||||||
|
os.rename("history.pickle.tmp", "history.pickle")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
for (pid, name) in processes:
|
for (pid, name) in processes:
|
||||||
row = [name]
|
row = [name]
|
||||||
for avg in self.AVERAGES:
|
for avg in self.AVERAGES:
|
||||||
|
|
Loading…
Reference in New Issue