From 3431d0a879d80233879fe7b35c37b2ca1dc36c22 Mon Sep 17 00:00:00 2001 From: shenyuhan Date: Tue, 19 Nov 2019 20:40:18 +0800 Subject: [PATCH] fix:1.Catch exception update_cache;2.add name&version hub run --- paddlehub/common/hub_server.py | 5 ++++- paddlehub/module/module.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/paddlehub/common/hub_server.py b/paddlehub/common/hub_server.py index ba770e28..4b7841c0 100644 --- a/paddlehub/common/hub_server.py +++ b/paddlehub/common/hub_server.py @@ -287,7 +287,10 @@ class CacheUpdater(threading.Thread): "command": "update_cache", "mtime": os.stat(cache_path).st_mtime } - r = srv_utils.hub_request(api_url, payload, extra) + try: + r = srv_utils.hub_request(api_url, payload, extra) + except Exception as err: + pass if r.get("update_cache", 0) == 1: with open(cache_path, 'w+') as fp: yaml.safe_dump({'resource_list': r['data']}, fp) diff --git a/paddlehub/module/module.py b/paddlehub/module/module.py index f508403c..206fceab 100644 --- a/paddlehub/module/module.py +++ b/paddlehub/module/module.py @@ -128,6 +128,8 @@ class Module(object): elif module_dir: self._init_with_module_file(module_dir=module_dir[0]) lock.flock(fp_lock, lock.LOCK_UN) + name = module_dir[0].split("/")[-1] + version = module_dir[1] elif signatures: if processor: if not issubclass(processor, BaseProcessor): -- GitLab