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:
parent
b204743e1b
commit
3b92b00d87
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue