[英]Python 3.6 web Sanic + uwsgi
i am trying to get my sanic webapp working with uwsgi and here is what i do: 我正在尝试让我的sanic webapp与uwsgi一起使用,这是我的工作:
Calling my uwsgi.ini file: 调用我的uwsgi.ini文件:
uwsgi uwsgi.ini
content: 内容:
[uwsgi]
http = :8001
wsgi-file = wsgi.py
asyncio = 10
wsgi.py: wsgi.py:
from app import app as application
if __name__ == "__main__":
application.run()
app.py: app.py:
import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
from sanic import Sanic
from sanic.response import json
app = Sanic(__name__)
@app.route("/")
async def test(request):
return json({"foo": "bar"})
When i request it, i get: 当我请求时,我得到:
TypeError: __call__() takes 1 positional argument but 3 were given
i checked uwsgi and Sanic docs but could find any hint...could anybody help me with this issue? 我检查了uwsgi和Sanic文档,但可以找到任何提示...有人可以帮助我解决这个问题吗? thanks and greetings! 谢谢和问候!
As far as I remember sanic is not WSGI compliant yet Make sanic WSGI compliant. 据我所知,sanic不符合WSGI,但仍使sanic符合WSGI。 #250 . #250 。
You can run it with gunicorn though, example: 您可以使用gunicorn来运行它,例如:
gunicorn myapp:app --bind 0.0.0.0:8080 --worker-class sanic.worker.GunicornWorker
You can also increase the sanic worker count to run on multiple CPU cores: 您还可以增加sanic worker数量以在多个CPU内核上运行:
app.run(host='0.0.0.0', port=1337, workers=4)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.