[英]multiprocessing.Process is blocking the return statement when running with uWSGI
I am running an API back and currently, I am using a subprocess.Popen
.我正在运行 API ,目前,我正在使用
subprocess.Popen
。 As the called modules are pure python my idea is to run it with multiprocessing.Process
or Pull
.由于被调用的模块是纯 python 我的想法是使用
multiprocessing.Process
或Pull
运行它。 The request is processed like this:请求是这样处理的:
Connexion
endpointConnexion
端点When replacing:更换时:
Popen(...)
with和
p = Process(target=...)
p.start()
this happens to multiprocessing with uwsgi:这发生在使用uwsgi 的多处理中:
Connexion
endpointConnexion
端点 in if I run it on https://github.com/tiangolo/uwsgi-nginx-flask-docker :如果我在https://github.com/tiangolo/uwsgi-nginx-flask-docker上运行它:
... ...
It works as espected if I run the process with python -m...
.如果我使用
python -m...
运行该过程,它会按预期工作。
My uwsgi.ini looks like this我的 uwsgi.ini 看起来像这样
[uwsgi]
module = myapp
callable = app
lazy-apps = true
stats-http = true
http = 127.0.0.1:8080
Your uwsgi.ini should enable threads, which are by default, blocked.您的 uwsgi.ini 应该启用默认情况下被阻止的线程。
Change it to the following将其更改为以下
[uwsgi]
module = myapp
callable = app
lazy-apps = true
stats-http = true
http = 127.0.0.1:8080
enable-threads = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.