Cache should check for success of func()

We return after checking if the fetcher function succeeds.  To do this
properly, we should store the value we get so that the cached file can
be closed before returning.
This commit is contained in:
Bryan Schumaker 2010-10-26 22:33:28 -04:00
parent b204743e1b
commit 3b92b00d87
1 changed files with 3 additions and 2 deletions

View File

@ -19,12 +19,13 @@ class CacheObject:
path = join(self.path, key)
if not exists(path):
f = open(path, 'w')
if func(f, *args):
return path
success = func(f, *args)
try:
f.close()
except:
pass
if success:
return path
else:
return path