Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
cfab962c
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
283
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cfab962c
编写于
9月 20, 2019
作者:
S
shenyuhan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add lock in module.__init()__
上级
04bd4c94
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
5 deletion
+4
-5
paddlehub/module/module.py
paddlehub/module/module.py
+4
-5
未找到文件。
paddlehub/module/module.py
浏览文件 @
cfab962c
...
...
@@ -120,12 +120,13 @@ class Module(object):
self
.
cache_program
=
None
fp_lock
=
open
(
os
.
path
.
join
(
CONF_HOME
,
'config.json'
))
lock
.
flock
(
fp_lock
,
lock
.
LOCK_EX
)
if
name
:
lock
.
flock
(
fp_lock
,
lock
.
LOCK_EX
)
self
.
_init_with_name
(
name
=
name
,
version
=
version
)
lock
.
flock
(
fp_lock
,
lock
.
LOCK_UN
)
elif
module_dir
:
self
.
_init_with_module_file
(
module_dir
=
module_dir
[
0
])
lock
.
flock
(
fp_lock
,
lock
.
LOCK_UN
)
elif
signatures
:
if
processor
:
if
not
issubclass
(
processor
,
BaseProcessor
):
...
...
@@ -139,11 +140,12 @@ class Module(object):
self
.
processor
=
processor
self
.
_generate_module_info
(
module_info
)
self
.
_init_with_signature
(
signatures
=
signatures
)
lock
.
flock
(
fp_lock
,
lock
.
LOCK_UN
)
else
:
lock
.
flock
(
fp_lock
,
lock
.
LOCK_UN
)
raise
ValueError
(
"Module initialized parameter is empty"
)
def
_init_with_name
(
self
,
name
,
version
=
None
):
lock
.
write_acquire
()
log_msg
=
"Installing %s module"
%
name
if
version
:
log_msg
+=
"-%s"
%
version
...
...
@@ -154,7 +156,6 @@ class Module(object):
logger
.
error
(
tips
)
exit
(
1
)
logger
.
info
(
tips
)
lock
.
write_release
()
self
.
_init_with_module_file
(
module_dir
[
0
])
def
_init_with_url
(
self
,
url
):
...
...
@@ -206,7 +207,6 @@ class Module(object):
self
.
assets
.
append
(
filepath
)
def
_init_with_module_file
(
self
,
module_dir
):
lock
.
write_acquire
()
checker
=
ModuleChecker
(
module_dir
)
checker
.
check
()
...
...
@@ -228,7 +228,6 @@ class Module(object):
self
.
_generate_extra_info
()
self
.
_restore_parameter
(
self
.
program
)
self
.
_recover_variable_info
(
self
.
program
)
lock
.
write_release
()
def
_init_with_signature
(
self
,
signatures
):
self
.
name_prefix
=
HUB_VAR_PREFIX
%
self
.
name
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录