Changeset 306ce5 in indico


Ignore:
Timestamp:
11/09/11 09:11:39 (19 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
8362d6
Parents:
cebb45b
Message:

[IMP] Upcoming Cache error handling

  • Ignore/log exceptions when reading from cache storage;
  • Regenerate cache;
  • Added try..finally to file cache, so that the file always gets unlocked;
Location:
indico
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/common/cache.py

    r2cbbaf r306ce5  
    146146        raise NotImplementedError 
    147147 
     148 
    148149@CacheStorage.register(True) 
    149150class FileCacheStorage(CacheStorage): 
     
    163164        f = open(filePath, 'wb') 
    164165        OSSpecific.lockFile(f, 'LOCK_EX') 
    165         pickle.dump(data, f) 
    166         OSSpecific.lockFile(f, 'LOCK_UN') 
    167         f.close() 
     166        try: 
     167            pickle.dump(data, f) 
     168        finally: 
     169            OSSpecific.lockFile(f, 'LOCK_UN') 
     170            f.close() 
    168171 
    169172    def load(self, path, name, default=None): 
     
    173176        f = open(filePath, 'rb') 
    174177        OSSpecific.lockFile(f, 'LOCK_SH') 
    175         obj = pickle.load(f) 
    176         mtime = os.path.getmtime(filePath) 
    177         OSSpecific.lockFile(f, 'LOCK_UN') 
    178         f.close() 
     178        try: 
     179            obj = pickle.load(f) 
     180            mtime = os.path.getmtime(filePath) 
     181        finally: 
     182            OSSpecific.lockFile(f, 'LOCK_UN') 
     183            f.close() 
    179184        return obj, mtime 
    180185 
  • indico/modules/upcoming.py

    r2cbbaf r306ce5  
    205205    def getUpcomingEventList(self): 
    206206 
    207         # check if there's a valid cached copy first 
    208         fromCache = self._cache.loadObject() 
     207        try: 
     208            # check if there's a valid cached copy first 
     209            fromCache = self._cache.loadObject() 
     210        except: 
     211            Logger.get('upcoming_events').exception("Upcoming events cache error") 
     212            fromCache = None 
    209213 
    210214        if fromCache: 
Note: See TracChangeset for help on using the changeset viewer.