简体   繁体   中英

Python 3.6 web Sanic + uwsgi

i am trying to get my sanic webapp working with uwsgi and here is what i do:

Calling my uwsgi.ini file:

uwsgi uwsgi.ini

content:

[uwsgi]
http = :8001
wsgi-file = wsgi.py
asyncio  = 10

wsgi.py:

from app import app as application

if __name__ == "__main__":
    application.run()

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? thanks and greetings!

As far as I remember sanic is not WSGI compliant yet Make sanic WSGI compliant. #250 .

You can run it with gunicorn though, example:

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:

app.run(host='0.0.0.0', port=1337, workers=4)

Follow this guide: Deploying

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM