Starting aiohttp server using gunicorn

I am trying to start an aiohttp based server using Gunicorn.

Here is the command:

gunicorn aiohttpdemo_polls:app --bind 127.0.0.1:8080

It returns:

Failed to find application: 'aiohttpdemo_polls' 

But when I run it with python -m as below:

python -m aiohttpdemo_polls

It works great. The code can be found from here , which is a demo application in the aiohttp repository. Also tried this as below:

gunicorn aiohttpdemo_polls.main:app --bind 127.0.0.1:8080

But also the server does not work. He returns

Failed to find application: 'aiohttpdemo_polls.main'

Any idea where to look next to fix the problem?

+4
source share
2 answers

The demo does not yet support the guns.

I registered a problem: https://github.com/aio-libs/aiohttp-demos/issues/10

Thanks for the report.

+1
source

aiohttp 3.1 factory, :

async def my_web_app():
    app = web.Application()
    app.router.add_get('/', index)
    return app

aiohttpdemo_polls .

gunicorn aiohttpdemo_polls.main:init_app --bind localhost:8080 --worker-class aiohttp.GunicornWebWorker
+1

Source: https://habr.com/ru/post/1689198/


All Articles