[csw-devel] SF.net SVN: gar:[20761] csw/mgar/gar/v2/lib/python/rest.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Apr 17 14:13:00 CEST 2013
Revision: 20761
http://gar.svn.sourceforge.net/gar/?rev=20761&view=rev
Author: wahwah
Date: 2013-04-17 12:13:00 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
pkgdb: Try to recover from bad local cache
If the local cache is corrupt and doesn't want to deserialize, try fetching
again.
I experienced it with a corrupt local BDB, but it didn't save me in the long
run. Nevertheless, some additional defense won't hurt.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/rest.py
Modified: csw/mgar/gar/v2/lib/python/rest.py
===================================================================
--- csw/mgar/gar/v2/lib/python/rest.py 2013-04-17 12:12:49 UTC (rev 20760)
+++ csw/mgar/gar/v2/lib/python/rest.py 2013-04-17 12:13:00 UTC (rev 20761)
@@ -219,12 +219,18 @@
self.d.close()
def GetPkgstats(self, md5):
+ pkgstats = None
if str(md5) in self.d:
- return cjson.decode(self.d[md5])
- else:
+ serialized_data = self.d[md5]
+ try:
+ return cjson.decode(serialized_data)
+ except (TypeError, cjson.DecodeError) as e:
+ logging.fatal('A problem with %r: %r', md5, e)
+ del self.d[md5]
+ if not pkgstats:
pkgstats = self.rest_client.GetPkgstatsByMd5(md5)
self.d[md5] = cjson.encode(pkgstats)
- return pkgstats
+ return pkgstats
def GetDeps(self, md5):
if str(md5) in self.deps:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list