Is Gunicorn's gthread async worker analogous to Waitress?
Asked Answered
O

2

11

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

Oblast answered 6/5, 2015 at 0:9 Comment(1)
I have never used waitress but looking at the Gunicorn code it is a simple wrapper around concurrent.futures. docs.python.org/3/library/concurrent.futures.htmlSanbenito
L
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].

Lavonia answered 24/7, 2016 at 18:25 Comment(0)
C
0

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.

Countrywide answered 9/3, 2020 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.