python 应用程序线程如何与 UWSGI 一起工作?
How does python application thread work with UWSGI?
我在 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
这个标志的含义是在禁用 uWSGI 线程的同时在脚本中启用线程。仅当您在脚本中实现了 threads 但不希望 uWSGI 启动它自己的线程时才需要它。
If you start uWSGI without threads, the Python GIL will not be
enabled, so threads generated by your application will never run.
<...>
If you want to maintain Python threads support without starting
multiple threads for your application, just add the --enable-threads
option (or enable-threads = true in ini style).
我在 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
这个标志的含义是在禁用 uWSGI 线程的同时在脚本中启用线程。仅当您在脚本中实现了 threads 但不希望 uWSGI 启动它自己的线程时才需要它。
If you start uWSGI without threads, the Python GIL will not be enabled, so threads generated by your application will never run.
<...>
If you want to maintain Python threads support without starting multiple threads for your application, just add the --enable-threads option (or enable-threads = true in ini style).