[Solved] gunicorn turns on gevent mode, and a timeout error is reported when the service is started, and the service cannot be started.

Error

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

Solution Reference:

It may be the coroutine model. The default value of worker_connections is too large, which makes it impossible to get up. If it is changed to multi-threading and gthread model, the service can be up.

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.

It has been said many times not to try to run pytorch or other blocking processes in the main worker process (or gevent). If you need to run a blocking process, run it as a separate daemon and use unix sockets to talk to it. Asyncio doesn’t change anything there either.

In short: start the process with a gunicorn request and have your client poll the system from time to time or wait for it in an unblocked fashion.