Is Gunicorn's gthread async worker analogous to Waitress?

社会主义新天地 提交于 2020-03-21 11:13:07

问题


I've read some posts from 2013 that the Gunicorn team was planning to build a threaded buffering layer worker model, similar to how Waitress works. Is that what the gthread async worker does? The gthread workers were released with version 19.0 in 2014.

Waitress has a master async thread that buffers requests, and enqueues each request to one of its sync worker threads when the request I/O is finished.

Gunicorn gthread doesn't have much documentation, but it sounds similar. From the docs:

The worker gthread is a threaded worker. It accepts connections in the main loop, accepted connections are are added to the thread pool as a connection job.

I only ask because I am not super knowledgeable about python async I/O code, though a cursory reading of the gthread.py seems to indicate that it is a socket-buffering process that protects worker threads from long-I/O requests (and buffers the response I/O as well).

https://github.com/benoitc/gunicorn/blob/master/gunicorn/workers/gthread.py


回答1:


The threaded worker in Gunicorn does not buffer I/O and does not read the request body in the main thread.

The main loop asynchronously handles calling accept()[1], but then the socket is immediately submitted to the thread pool[2].




回答2:


Gunicorn doesn't have HTTP request buffering, which is something you can find in Waitress. Waitress also has the advantage that it fully supports Windows.



来源:https://stackoverflow.com/questions/30065314/is-gunicorns-gthread-async-worker-analogous-to-waitress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!