uWSGI and Python > 3.4

女生的网名这么多〃 提交于 2019-12-12 10:57:16

问题


I have a django project currently running with the following configuration:

  • Debian 8
  • Python 3.4
  • uWSGI in emperor mode

I installed Python 3.6.1 from source and created a new virtual environment with python 3.6 (I use virtualenvwrapper), but I seem to have some trouble getting the project to start up with uwsgi.

Config file is as follows:

[uwsgi]
plugins = python3
project = %n
module = myapp.wsgi:application
home = path_to_new_env
socket = /var/run/uwsgi-%n.sock
chdir = path_to_new_env/myapp/myapp
processes = 4
max-requests = 5000
chmod-socket = 666
chown-socket = user:user
master = True
vacuum = True
logto = /var/log/%n_LOG.log
buffer-size = 32768

I was under the impression that the python3 plugin would include support for python 3.6, but the log indicates that the Python 3.4.x interpreter is still being used.

In my list of installed uwsgi plugins, I see support for python 2, 3 and 3.4 but nothing more. I'm not sure what needs to be done to have the correct interpreter set on startup.

Any advice would be appreciated.

UPDATE: I've tried building a uwsgi plugin for python 3.6:

root@app:~# PYTHON=python3.6 uwsgi --build-plugin "/root/uwsgi-2.0.15/plugins/python python36"
*** uWSGI building and linking plugin from /root/uwsgi-2.0.15/plugins/python ***
[gcc -pthread] python36_plugin.so
/root/uwsgi-2.0.15/plugins/python/python_plugin.c: In function ‘uwsgi_python_atexit’:
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:380:11: error: ‘struct uwsgi_server’ has no member named ‘skip_atexit_teardown’
  if (uwsgi.skip_atexit_teardown)
           ^
/root/uwsgi-2.0.15/plugins/python/python_plugin.c: At top level:
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: unknown field ‘worker’ specified in initializer
  .worker = uwsgi_python_worker,
  ^
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: initialization from incompatible pointer type [-Werror]
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: (near initialization for ‘python36_plugin.exception_class’) [-Werror]
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: initialized field overwritten [-Werror=override-init]
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: (near initialization for ‘python36_plugin.exception_class’) [-Werror=override-init]
cc1: all warnings being treated as errors
/root/uwsgi-2.0.15/plugins/python/uwsgi_pymodule.c: In function ‘py_uwsgi_spooler_get_task’:
/root/uwsgi-2.0.15/plugins/python/uwsgi_pymodule.c:2107:2: error: implicit declaration of function ‘uwsgi_spooler_read_header’ [-Werror=implicit-function-declaration]
  if (uwsgi_spooler_read_header(task_path, spool_fd, &uh) ||
  ^
/root/uwsgi-2.0.15/plugins/python/uwsgi_pymodule.c:2108:3: error: implicit declaration of function ‘uwsgi_spooler_read_content’ [-Werror=implicit-function-declaration]
   uwsgi_spooler_read_content(spool_fd, spool_buf, &body, &body_len, &uh, &task_stat)) {
   ^
cc1: all warnings being treated as errors
*** unable to build python36 plugin ***

回答1:


I've recently came up with a solution to python3.6 apps with uwsgi server.

wget https://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar -xvzf uwsgi-latest.tar.gz

mv uwsgi-2.0.17 uwsgi
cd uwsgi
make PROFILE=nolang # no language defaults allows flexibility for python versions

PYTHON=python3.6 # or --> PYTHON=/usr/bin/python3.6

./uwsgi --build-plugin "plugins/python python36"
mv python36_plugin.so plugins/python
cd ..
sudo mv uwsgi /usr/local
sudo ln -s /usr/local/uwsgi/uwsgi /usr/local/bin/uwsgi

Then, you can use it in configuration files as follows:

[uwsgi]

plugins-dir = /usr/local/uwsgi/plugins/python
plugin = python36

Mimic this process for any other python version you'd like to have available on the uwsgi server.
More help here.




回答2:


Solution:

1) Download uwsgi source tarball

2) Follow build instructions here

Note that for python3.6, you need to configure python with the --enable-shared flag as well as declare an extra environment variable before building the uWsgi plugin: export CFLAGS="$CFLAGS -fPIC"

3) Install new uwsgi binary with supported plugins: cp uwsgi /usr/local/bin/



来源:https://stackoverflow.com/questions/44556281/uwsgi-and-python-3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!