Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
e6de6b93
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看板
提交
e6de6b93
编写于
6月 15, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for python2, Queue is empty right after put from the same process/thread
上级
c5d98039
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
24 deletion
+69
-24
python/paddle_serving_server/pyserver.py
python/paddle_serving_server/pyserver.py
+34
-12
python/paddle_serving_server_gpu/pyserver.py
python/paddle_serving_server_gpu/pyserver.py
+34
-12
python/requirements.txt
python/requirements.txt
+1
-0
未找到文件。
python/paddle_serving_server/pyserver.py
浏览文件 @
e6de6b93
...
...
@@ -215,7 +215,13 @@ class Channel(multiprocessing.queues.Queue):
def
__init__
(
self
,
manager
,
name
=
None
,
maxsize
=
0
,
timeout
=
None
):
# https://stackoverflow.com/questions/39496554/cannot-subclass-multiprocessing-queue-in-python-3-5/
multiprocessing
.
queues
.
Queue
.
__init__
(
self
,
maxsize
=
maxsize
)
if
sys
.
version_info
.
major
==
2
:
super
(
Channel
,
self
).
__init__
(
maxsize
=
maxsize
)
elif
sys
.
version_info
.
major
==
3
:
super
(
Channel
,
self
).
__init__
(
maxsize
=
maxsize
,
ctx
=
multiprocessing
.
get_context
())
else
:
raise
Exception
(
"Error Python version"
)
self
.
_maxsize
=
maxsize
self
.
_timeout
=
timeout
self
.
name
=
name
...
...
@@ -355,17 +361,25 @@ class Channel(multiprocessing.queues.Queue):
while
self
.
_stop
is
False
and
resp
is
None
:
try
:
logging
.
debug
(
self
.
_log
(
"{} try to get(with channel size: {})"
.
format
(
op_name
,
self
.
qsize
())))
#TODO: bug to fix
# (multiple processes) the queue is not empty, but it raise Queue.Empty
resp
=
self
.
get
(
timeout
=
1e-3
)
self
.
_log
(
"{} try to get(with channel empty: {})"
.
format
(
op_name
,
self
.
empty
())))
# For Python2, after putting an object on an empty queue there may
# be an infinitessimal delay before the queue's :meth:`~Queue.empty`
# see more:
# - https://bugs.python.org/issue18277
# - https://hg.python.org/cpython/rev/860fc6a2bd21
if
sys
.
version_info
.
major
==
2
:
resp
=
self
.
get
(
timeout
=
1e-3
)
elif
sys
.
version_info
.
major
==
3
:
resp
=
self
.
get
(
timeout
=
0
)
else
:
raise
Exception
(
"Error Python version"
)
break
except
Queue
.
Empty
:
logging
.
debug
(
self
.
_log
(
"{} wait for empty queue(with channel
size
: {})"
.
format
(
op_name
,
self
.
qsize
())))
"{} wait for empty queue(with channel
empty
: {})"
.
format
(
op_name
,
self
.
empty
())))
self
.
_cv
.
wait
()
logging
.
debug
(
self
.
_log
(
"{} get data succ: {}"
.
format
(
op_name
,
resp
.
__str__
(
...
...
@@ -390,9 +404,17 @@ class Channel(multiprocessing.queues.Queue):
logging
.
debug
(
self
.
_log
(
"{} try to get(with channel size: {})"
.
format
(
op_name
,
self
.
qsize
())))
#TODO: bug to fix
# (multiple processes) the queue is not empty, but it raise Queue.Empty
channeldata
=
self
.
get
(
timeout
=
1e-3
)
# For Python2, after putting an object on an empty queue there may
# be an infinitessimal delay before the queue's :meth:`~Queue.empty`
# see more:
# - https://bugs.python.org/issue18277
# - https://hg.python.org/cpython/rev/860fc6a2bd21
if
sys
.
version_info
.
major
==
2
:
channeldata
=
self
.
get
(
timeout
=
1e-3
)
elif
sys
.
version_info
.
major
==
3
:
channeldata
=
self
.
get
(
timeout
=
0
)
else
:
raise
Exception
(
"Error Python version"
)
self
.
_front_res
.
append
(
channeldata
)
break
except
Queue
.
Empty
:
...
...
@@ -798,7 +820,7 @@ class VirtualOp(Op):
class
GeneralPythonService
(
general_python_service_pb2_grpc
.
GeneralPythonService
):
general_python_service_pb2_grpc
.
GeneralPythonService
Servicer
):
def
__init__
(
self
,
in_channel
,
out_channel
,
retry
=
2
):
super
(
GeneralPythonService
,
self
).
__init__
()
self
.
name
=
"#G"
...
...
python/paddle_serving_server_gpu/pyserver.py
浏览文件 @
e6de6b93
...
...
@@ -215,7 +215,13 @@ class Channel(multiprocessing.queues.Queue):
def
__init__
(
self
,
manager
,
name
=
None
,
maxsize
=
0
,
timeout
=
None
):
# https://stackoverflow.com/questions/39496554/cannot-subclass-multiprocessing-queue-in-python-3-5/
multiprocessing
.
queues
.
Queue
.
__init__
(
self
,
maxsize
=
maxsize
)
if
sys
.
version_info
.
major
==
2
:
super
(
Channel
,
self
).
__init__
(
maxsize
=
maxsize
)
elif
sys
.
version_info
.
major
==
3
:
super
(
Channel
,
self
).
__init__
(
maxsize
=
maxsize
,
ctx
=
multiprocessing
.
get_context
())
else
:
raise
Exception
(
"Error Python version"
)
self
.
_maxsize
=
maxsize
self
.
_timeout
=
timeout
self
.
name
=
name
...
...
@@ -355,17 +361,25 @@ class Channel(multiprocessing.queues.Queue):
while
self
.
_stop
is
False
and
resp
is
None
:
try
:
logging
.
debug
(
self
.
_log
(
"{} try to get(with channel size: {})"
.
format
(
op_name
,
self
.
qsize
())))
#TODO: bug to fix
# (multiple processes) the queue is not empty, but it raise Queue.Empty
resp
=
self
.
get
(
timeout
=
1e-3
)
self
.
_log
(
"{} try to get(with channel empty: {})"
.
format
(
op_name
,
self
.
empty
())))
# For Python2, after putting an object on an empty queue there may
# be an infinitessimal delay before the queue's :meth:`~Queue.empty`
# see more:
# - https://bugs.python.org/issue18277
# - https://hg.python.org/cpython/rev/860fc6a2bd21
if
sys
.
version_info
.
major
==
2
:
resp
=
self
.
get
(
timeout
=
1e-3
)
elif
sys
.
version_info
.
major
==
3
:
resp
=
self
.
get
(
timeout
=
0
)
else
:
raise
Exception
(
"Error Python version"
)
break
except
Queue
.
Empty
:
logging
.
debug
(
self
.
_log
(
"{} wait for empty queue(with channel
size
: {})"
.
format
(
op_name
,
self
.
qsize
())))
"{} wait for empty queue(with channel
empty
: {})"
.
format
(
op_name
,
self
.
empty
())))
self
.
_cv
.
wait
()
logging
.
debug
(
self
.
_log
(
"{} get data succ: {}"
.
format
(
op_name
,
resp
.
__str__
(
...
...
@@ -390,9 +404,17 @@ class Channel(multiprocessing.queues.Queue):
logging
.
debug
(
self
.
_log
(
"{} try to get(with channel size: {})"
.
format
(
op_name
,
self
.
qsize
())))
#TODO: bug to fix
# (multiple processes) the queue is not empty, but it raise Queue.Empty
channeldata
=
self
.
get
(
timeout
=
1e-3
)
# For Python2, after putting an object on an empty queue there may
# be an infinitessimal delay before the queue's :meth:`~Queue.empty`
# see more:
# - https://bugs.python.org/issue18277
# - https://hg.python.org/cpython/rev/860fc6a2bd21
if
sys
.
version_info
.
major
==
2
:
channeldata
=
self
.
get
(
timeout
=
1e-3
)
elif
sys
.
version_info
.
major
==
3
:
channeldata
=
self
.
get
(
timeout
=
0
)
else
:
raise
Exception
(
"Error Python version"
)
self
.
_front_res
.
append
(
channeldata
)
break
except
Queue
.
Empty
:
...
...
@@ -798,7 +820,7 @@ class VirtualOp(Op):
class
GeneralPythonService
(
general_python_service_pb2_grpc
.
GeneralPythonService
):
general_python_service_pb2_grpc
.
GeneralPythonService
Servicer
):
def
__init__
(
self
,
in_channel
,
out_channel
,
retry
=
2
):
super
(
GeneralPythonService
,
self
).
__init__
()
self
.
name
=
"#G"
...
...
python/requirements.txt
浏览文件 @
e6de6b93
numpy>=1.12, <=1.16.4 ; python_version<"3.5"
grpcio-tools>=1.28.1
grpcio>=1.28.1
func-timeout==4.3.5
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录