提交 504f6d95 编写于 作者: H hj

Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleHub into multimachine

...@@ -283,17 +283,23 @@ class CacheUpdater(threading.Thread): ...@@ -283,17 +283,23 @@ class CacheUpdater(threading.Thread):
api_url = srv_utils.uri_path(default_hub_server.get_server_url(), api_url = srv_utils.uri_path(default_hub_server.get_server_url(),
'search') 'search')
cache_path = os.path.join(CACHE_HOME, RESOURCE_LIST_FILE) cache_path = os.path.join(CACHE_HOME, RESOURCE_LIST_FILE)
extra = { if os.path.exists(cache_path):
"command": "update_cache", extra = {
"mtime": os.stat(cache_path).st_mtime "command": "update_cache",
} "mtime": os.stat(cache_path).st_mtime
}
else:
extra = {
"command": "update_cache",
"mtime": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
}
try: try:
r = srv_utils.hub_request(api_url, payload, extra) r = srv_utils.hub_request(api_url, payload, extra)
if r.get("update_cache", 0) == 1:
with open(cache_path, 'w+') as fp:
yaml.safe_dump({'resource_list': r['data']}, fp)
except Exception as err: except Exception as err:
pass pass
if r.get("update_cache", 0) == 1:
with open(cache_path, 'w+') as fp:
yaml.safe_dump({'resource_list': r['data']}, fp)
def run(self): def run(self):
self.update_resource_list_file(self.module, self.version) self.update_resource_list_file(self.module, self.version)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册