Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
d2028c34
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d2028c34
编写于
7月 02, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
only executes init_op once in multi-thread version
上级
9aeccd3f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
12 deletion
+24
-12
python/pipeline/operator.py
python/pipeline/operator.py
+24
-12
未找到文件。
python/pipeline/operator.py
浏览文件 @
d2028c34
...
@@ -174,23 +174,30 @@ class Op(object):
...
@@ -174,23 +174,30 @@ class Op(object):
p
=
multiprocessing
.
Process
(
p
=
multiprocessing
.
Process
(
target
=
self
.
_run
,
target
=
self
.
_run
,
args
=
(
concurrency_idx
,
self
.
_get_input_channel
(),
args
=
(
concurrency_idx
,
self
.
_get_input_channel
(),
self
.
_get_output_channels
(),
client_type
))
self
.
_get_output_channels
(),
client_type
,
False
))
p
.
start
()
p
.
start
()
proces
.
append
(
p
)
proces
.
append
(
p
)
return
proces
return
proces
def
start_with_thread
(
self
,
client_type
):
def
start_with_thread
(
self
,
client_type
):
# load user resources
try
:
self
.
init_op
()
except
Exception
as
e
:
_LOGGER
.
error
(
log
(
e
))
os
.
_exit
(
-
1
)
threads
=
[]
threads
=
[]
for
concurrency_idx
in
range
(
self
.
concurrency
):
for
concurrency_idx
in
range
(
self
.
concurrency
):
t
=
threading
.
Thread
(
t
=
threading
.
Thread
(
target
=
self
.
_run
,
target
=
self
.
_run
,
args
=
(
concurrency_idx
,
self
.
_get_input_channel
(),
args
=
(
concurrency_idx
,
self
.
_get_input_channel
(),
self
.
_get_output_channels
(),
client_type
))
self
.
_get_output_channels
(),
client_type
,
True
))
t
.
start
()
t
.
start
()
threads
.
append
(
t
)
threads
.
append
(
t
)
return
threads
return
threads
def
load_user_resources
(
self
):
def
init_op
(
self
):
pass
pass
def
_run_preprocess
(
self
,
parsed_data
,
data_id
,
log_func
):
def
_run_preprocess
(
self
,
parsed_data
,
data_id
,
log_func
):
...
@@ -309,8 +316,8 @@ class Op(object):
...
@@ -309,8 +316,8 @@ class Op(object):
data_id
=
data_id
)
data_id
=
data_id
)
return
output_data
,
error_channeldata
return
output_data
,
error_channeldata
def
_run
(
self
,
concurrency_idx
,
input_channel
,
output_channels
,
def
_run
(
self
,
concurrency_idx
,
input_channel
,
output_channels
,
client_type
,
client_type
):
use_multithread
):
def
get_log_func
(
op_info_prefix
):
def
get_log_func
(
op_info_prefix
):
def
log_func
(
info_str
):
def
log_func
(
info_str
):
return
"{} {}"
.
format
(
op_info_prefix
,
info_str
)
return
"{} {}"
.
format
(
op_info_prefix
,
info_str
)
...
@@ -329,13 +336,18 @@ class Op(object):
...
@@ -329,13 +336,18 @@ class Op(object):
self
.
_server_endpoints
,
self
.
_fetch_names
)
self
.
_server_endpoints
,
self
.
_fetch_names
)
if
client
is
not
None
:
if
client
is
not
None
:
client_predict_handler
=
client
.
predict
client_predict_handler
=
client
.
predict
# load user resources
self
.
load_user_resources
()
except
Exception
as
e
:
except
Exception
as
e
:
_LOGGER
.
error
(
log
(
e
))
_LOGGER
.
error
(
log
(
e
))
os
.
_exit
(
-
1
)
os
.
_exit
(
-
1
)
if
not
use_multithread
:
# load user resources
try
:
self
.
init_op
()
except
Exception
as
e
:
_LOGGER
.
error
(
log
(
e
))
os
.
_exit
(
-
1
)
self
.
_is_run
=
True
self
.
_is_run
=
True
while
self
.
_is_run
:
while
self
.
_is_run
:
self
.
_profiler_record
(
"{}-get#{}_0"
.
format
(
op_info_prefix
,
tid
))
self
.
_profiler_record
(
"{}-get#{}_0"
.
format
(
op_info_prefix
,
tid
))
...
@@ -399,7 +411,7 @@ class RequestOp(Op):
...
@@ -399,7 +411,7 @@ class RequestOp(Op):
name
=
"#G"
,
input_ops
=
[],
concurrency
=
concurrency
)
name
=
"#G"
,
input_ops
=
[],
concurrency
=
concurrency
)
# load user resources
# load user resources
try
:
try
:
self
.
load_user_resources
()
self
.
init_op
()
except
Exception
as
e
:
except
Exception
as
e
:
_LOGGER
.
error
(
log
(
e
))
_LOGGER
.
error
(
log
(
e
))
os
.
_exit
(
-
1
)
os
.
_exit
(
-
1
)
...
@@ -424,7 +436,7 @@ class ResponseOp(Op):
...
@@ -424,7 +436,7 @@ class ResponseOp(Op):
name
=
"#R"
,
input_ops
=
input_ops
,
concurrency
=
concurrency
)
name
=
"#R"
,
input_ops
=
input_ops
,
concurrency
=
concurrency
)
# load user resources
# load user resources
try
:
try
:
self
.
load_user_resources
()
self
.
init_op
()
except
Exception
as
e
:
except
Exception
as
e
:
_LOGGER
.
error
(
log
(
e
))
_LOGGER
.
error
(
log
(
e
))
os
.
_exit
(
-
1
)
os
.
_exit
(
-
1
)
...
@@ -490,8 +502,8 @@ class VirtualOp(Op):
...
@@ -490,8 +502,8 @@ class VirtualOp(Op):
channel
.
add_producer
(
op_name
)
channel
.
add_producer
(
op_name
)
self
.
_outputs
.
append
(
channel
)
self
.
_outputs
.
append
(
channel
)
def
_run
(
self
,
concurrency_idx
,
input_channel
,
output_channels
,
def
_run
(
self
,
concurrency_idx
,
input_channel
,
output_channels
,
client_type
,
client_type
):
use_multithread
):
def
get_log_func
(
op_info_prefix
):
def
get_log_func
(
op_info_prefix
):
def
log_func
(
info_str
):
def
log_func
(
info_str
):
return
"{} {}"
.
format
(
op_info_prefix
,
info_str
)
return
"{} {}"
.
format
(
op_info_prefix
,
info_str
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录