Fix thread local cache use

This commit is contained in:
mvdbeek
2017-05-01 16:06:47 +02:00
parent b4e4f3ce7a
commit ff1b66afb3
+6 -2
View File
@@ -101,9 +101,13 @@ class ToolShedRepositoryCache(object):
@property
def tool_shed_repositories(self):
if time.time() - self.time > 1 or not hasattr(self.cache, 'repositories '): # If cache is older than 1 second we refresh
if time.time() - self.time > 1: # If cache is older than 1 second we refresh
self.rebuild()
return self.cache.repositories
try:
return self.cache.repositories
except AttributeError:
self.rebuild()
return self.cache.repositories
def rebuild(self):
self.cache.repositories = self.app.install_model.context.current.query(self.app.install_model.ToolShedRepository).all()