Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
f3ac1e38
S
Serving
项目概览
PaddlePaddle
/
Serving
接近 2 年 前同步成功
通知
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看板
提交
f3ac1e38
编写于
7月 02, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug: client in multi-thread-op
上级
6722b83c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
16 deletion
+24
-16
python/pipeline/operator.py
python/pipeline/operator.py
+24
-16
未找到文件。
python/pipeline/operator.py
浏览文件 @
f3ac1e38
...
...
@@ -71,18 +71,19 @@ class Op(object):
fetch_names
):
if
self
.
with_serving
==
False
:
_LOGGER
.
debug
(
"{} no client"
.
format
(
self
.
name
))
return
return
None
_LOGGER
.
debug
(
"{} client_config: {}"
.
format
(
self
.
name
,
client_config
))
_LOGGER
.
debug
(
"{} fetch_names: {}"
.
format
(
self
.
name
,
fetch_names
))
if
client_type
==
'brpc'
:
self
.
_
client
=
Client
()
self
.
_
client
.
load_client_config
(
client_config
)
client
=
Client
()
client
.
load_client_config
(
client_config
)
elif
client_type
==
'grpc'
:
self
.
_
client
=
MultiLangClient
()
client
=
MultiLangClient
()
else
:
raise
ValueError
(
"unknow client type: {}"
.
format
(
client_type
))
self
.
_
client
.
connect
(
server_endpoints
)
client
.
connect
(
server_endpoints
)
self
.
_fetch_names
=
fetch_names
return
client
def
_get_input_channel
(
self
):
return
self
.
_input
...
...
@@ -130,14 +131,12 @@ class Op(object):
(
_
,
input_dict
),
=
input_dicts
.
items
()
return
input_dict
def
process
(
self
,
feed_dict
):
def
process
(
self
,
client_predict_handler
,
feed_dict
):
err
,
err_info
=
ChannelData
.
check_npdata
(
feed_dict
)
if
err
!=
0
:
raise
NotImplementedError
(
"{} Please override preprocess func."
.
format
(
err_info
))
_LOGGER
.
debug
(
self
.
_log
(
'feed_dict: {}'
.
format
(
feed_dict
)))
_LOGGER
.
debug
(
self
.
_log
(
'fetch: {}'
.
format
(
self
.
_fetch_names
)))
call_result
=
self
.
_client
.
predict
(
call_result
=
client_predict_handler
(
feed
=
feed_dict
,
fetch
=
self
.
_fetch_names
)
_LOGGER
.
debug
(
self
.
_log
(
"get call_result"
))
return
call_result
...
...
@@ -222,13 +221,15 @@ class Op(object):
data_id
=
data_id
)
return
preped_data
,
error_channeldata
def
_run_process
(
self
,
preped_data
,
data_id
,
log_func
):
def
_run_process
(
self
,
client_predict_handler
,
preped_data
,
data_id
,
log_func
):
midped_data
,
error_channeldata
=
None
,
None
if
self
.
with_serving
:
ecode
=
ChannelDataEcode
.
OK
.
value
if
self
.
_timeout
<=
0
:
try
:
midped_data
=
self
.
process
(
preped_data
)
midped_data
=
self
.
process
(
client_predict_handler
,
preped_data
)
except
Exception
as
e
:
ecode
=
ChannelDataEcode
.
UNKNOW
.
value
error_info
=
log_func
(
e
)
...
...
@@ -237,7 +238,11 @@ class Op(object):
for
i
in
range
(
self
.
_retry
):
try
:
midped_data
=
func_timeout
.
func_timeout
(
self
.
_timeout
,
self
.
process
,
args
=
(
preped_data
,
))
self
.
_timeout
,
self
.
process
,
args
=
(
client_predict_handler
,
preped_data
,
))
except
func_timeout
.
FunctionTimedOut
as
e
:
if
i
+
1
>=
self
.
_retry
:
ecode
=
ChannelDataEcode
.
TIMEOUT
.
value
...
...
@@ -316,8 +321,11 @@ class Op(object):
tid
=
threading
.
current_thread
().
ident
# create client based on client_type
self
.
init_client
(
client_type
,
self
.
_client_config
,
self
.
_server_endpoints
,
self
.
_fetch_names
)
client
=
self
.
init_client
(
client_type
,
self
.
_client_config
,
self
.
_server_endpoints
,
self
.
_fetch_names
)
client_predict_handler
=
None
if
self
.
with_serving
:
client_predict_handler
=
client
.
predict
# load user resources
self
.
load_user_resources
()
...
...
@@ -349,8 +357,8 @@ class Op(object):
# process
self
.
_profiler_record
(
"{}-midp#{}_0"
.
format
(
op_info_prefix
,
tid
))
midped_data
,
error_channeldata
=
self
.
_run_process
(
preped_data
,
data_id
,
log
)
midped_data
,
error_channeldata
=
self
.
_run_process
(
client_predict_handler
,
preped_data
,
data_id
,
log
)
self
.
_profiler_record
(
"{}-midp#{}_1"
.
format
(
op_info_prefix
,
tid
))
if
error_channeldata
is
not
None
:
self
.
_push_to_output_channels
(
error_channeldata
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录