gunicorn开启gevent模式,启动服务的时候报超时错误,服务起不来

报错

 [[2022-08-25 08:26:45 +0000]] CRITICAL [glogging.py:255] WORKER TIMEOUT (pid:669)'

在这里插入图片描述

解决方案参考:

有可能是协程模型,worker_connections 的默认值过大,导致起不来,改成多线程,gthread模型,服务就可以起来。

https://github.com/benoitc/gunicorn/issues/2608
https://github.com/benoitc/gunicorn/issues/1840

It has been said many time to not ry to ru a pytorch or other blocking process in main worker processes (or in gevent). If you need to orun a blocking process, run it as a separate daemon and dialog with it using unix sockets . Asyncio will not change anything as well there.
So in short: start the process from a gunicorn request, and make your client polling the sytem from time to time or wait for it in an unblocking manner.

It has been said many time to not ry to ru a pytorch or other blocking process in main worker processes (or in gevent). If you need to orun a blocking process, run it as a separate daemon and dialog with it using unix sockets . Asyncio will not change anything as well there.

So in short: start the process from a gunicorn request, and make your client polling the sytem from time to time or wait for it in an unblocking manner.

已经说过很多次不要尝试在主工作进程(或 gevent)中运行 pytorch 或其他阻塞进程。 如果您需要运行阻塞进程,请将其作为单独的守护进程运行并使用 unix sockets 与之对话。 Asyncio 也不会在那里改变任何东西。

简而言之:从 gunicorn 请求开始该过程,并让您的客户端不时轮询系统或以畅通无阻的方式等待它。

猜你喜欢

转载自blog.csdn.net/qq_15821487/article/details/126527809