python应用程序线程如何与UWSGI一起使用?

问题描述 投票:0回答:1

我有一个在uwsgi后面运行的python flask应用程序。下面是我用来启动应用程序的脚本。如您所见,脚本中有--enable-threads标志。根据uwsgi文件,它说:If you want to maintain Python threads support without starting multiple threads for your application, just add the --enable-threads option。但是我不理解threads support without starting multiple threads的含义。如果我不想启动多个线程,为什么我需要启用线程?

uwsgi \
  --uid uwsgi \
  --master \
  --plugins http,python3,stats_pusher_statsd \
  --http :8080 \
  --buffer-size 32768 \
  --enable-threads \
  --wsgi-file api/uwsgi.py

python uwsgi
1个回答
0
投票

此标志的含义是在禁用uWSGI线程时启用脚本中的线程。仅当您在脚本中实现了threads但不希望uWSGI启动其自己的线程时,才需要使用它。

Original description

如果您在没有线程的情况下启动uWSGI,Python GIL将不会启用,因此您的应用程序生成的线程将永远不会运行。

<...>

如果您想不启动就维护Python线程支持,您的应用程序有多个线程,只需添加--enable-threads选项(或ini样式中的enable-threads = true)。

© www.soinside.com 2019 - 2024. All rights reserved.