如果我在Django项目的`wsgi.py`中使用eventlet.wsgi,我可以使用uWSGI来生成我的应用程序吗?

时间:2018-05-09 12:07:54

标签: python uwsgi

如果我在Django项目的wsgi.py中使用eventlet,我可以使用uWSGI吗?

在我的项目中wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AProject.settings")


from socketio import Middleware
from xxx.website_chat.views import sio
django_app = get_wsgi_application()
application = Middleware(sio, django_app)

import eventlet
import eventlet.wsgi
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)

我使用eventlet.wsgi.server()做我的应用程序,无论我分发项目时,还是需要uWSGI作为网络服务器吗?

修改-1

我的意思是,如果我使用下面的代码,我仍然需要uWSGI作为网络服务器:

eventlet.wsgi.server(eventlet.listen(('', 8000)), application)

修改-2

我在项目eventlet.wsgi.server中使用wsgi.py

import eventlet.wsgi eventlet.wsgi.server(eventlet.listen(('', 8000)), application)

现在我想发布我的项目。

当我使用uwsgi --ini uwsgi.ini时:

会出现以下错误:

mapped 208320 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
django.setup()
Traceback (most recent call last):
  File "myProject/wsgi.py", line 30, in <module>
    eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
  File "/Users/lll/Desktop/myProject/Project/myProject/venv/lib/python3.5/site-packages/eventlet/convenience.py", line 78, in listen
    sock.bind(addr)
OSError: [Errno 48] Address already in use
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 11413)
spawned uWSGI worker 1 (pid: 11418, cores: 4)
spawned uWSGI http 1 (pid: 11419)

我使用lsof -i:8000发现uwsgi正在使用8000端口。

$ lsof -i:8000
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
uwsgi   11413  ldl    4u  IPv4 0x9bf2de3fe3ee0367      0t0  TCP *:irdmi (LISTEN)
uwsgi   11419  ldl    4u  IPv4 0x9bf2de3fe3ee0367      0t0  TCP *:irdmi (LISTEN)

所以eventlet.wsgi无法收听地址:eventlet.listen(('', 8000))

当我分发我的项目时,我不需要uWSGI吗?直接使用eventlet.wsgi.server?

0 个答案:

没有答案