使用gunicorn运行aiohttp服务器

2024-04-16 20:21:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Gunicorn运行一个基于aiohttp的服务器。在

命令如下:

gunicorn aiohttpdemo_polls:app --bind 127.0.0.1:8080

它返回:

^{pr2}$

但当我使用python-m运行它时,如下所示:

python -m aiohttpdemo_polls

它工作得很好。代码可以从here找到,这是aiohttp repo中的一个演示应用程序。 也尝试了如下:

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

但它也不运行服务器。它回来了

Failed to find application: 'aiohttpdemo_polls.main'

你知道在哪里进一步解决这个问题吗?在


Tags: 代码命令服务器app应用程序aiohttpherebind
2条回答

aiohttp 3.1支持coroutine as application factory,例如:

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

aiohttpdemo_投票的Current implementation使用这种方法。可以从

^{pr2}$

演示还不支持gunicorn。在

我提出了一个问题:https://github.com/aio-libs/aiohttp-demos/issues/10

谢谢你的报告。在

相关问题 更多 >