From d278b1220fcbd65e95aa4812913e8c370904f50e Mon Sep 17 00:00:00 2001 From: david-sarah Date: Mon, 2 Jul 2012 18:15:55 +0000 Subject: [PATCH] If a stats.pickle file cannot be read, print a better error message. --- src/allmydata/stats.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/allmydata/stats.py b/src/allmydata/stats.py index 5c1cdb3d..ea0a7f85 100644 --- a/src/allmydata/stats.py +++ b/src/allmydata/stats.py @@ -12,6 +12,7 @@ from zope.interface import implements from foolscap.api import eventually, DeadReferenceError, Referenceable, Tub from allmydata.util import log +from allmydata.util.encodingutil import quote_output from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer class LoadMonitor(service.MultiService): @@ -252,7 +253,12 @@ class PickleStatsGatherer(StdOutStatsGatherer): if os.path.exists(self.picklefile): f = open(self.picklefile, 'rb') - self.gathered_stats = pickle.load(f) + try: + self.gathered_stats = pickle.load(f) + except Exception: + print ("Error while attempting to load pickle file %s.\nYou may need to delete this file.\n" % + quote_output(os.path.abspath(self.picklefile))) + raise f.close() else: self.gathered_stats = {} -- 2.37.2