提交 73e68b4b 编写于 作者: W wuzewu

Add lock when install HubModule

上级 be093813
......@@ -19,7 +19,9 @@ import sys
from collections import OrderedDict
from typing import List
from paddlehub.env import MODULE_HOME
import filelock
from paddlehub.env import MODULE_HOME, TMP_HOME
from paddlehub.module.module import Module as HubModule
from paddlehub.server import module_server
from paddlehub.utils import xarfile, log, utils, pypi
......@@ -100,6 +102,8 @@ class LocalModuleManager(object):
source (str|optional): source containing module code, use with name paramete
'''
if name:
lock = filelock.FileLock(os.path.join(TMP_HOME, name))
with lock:
hub_module_cls = self.search(name)
if hub_module_cls and hub_module_cls.version.match(version):
directory = self._get_normalized_path(hub_module_cls.name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册