title: How does Waitress handle concurrent tasks?
body: <p>I'm trying to build a python webserver using Django and Waitress, but I'd like to know how Waitress handles concurrent requests, and when <em>blocking</em> may occur.</p>
  
  <hr>
  
  <p>While the <a href="https://docs.pylonsproject.org/projects/waitress/en/stable/design.html" rel="noreferrer">Waitress documentation</a> mentions that multiple worker threads are available, it doesn't provide a lot of information on how they are implemented and how the python GIL affects them (emphasis my own):</p>
  
  <blockquote>
    <p>When a channel determines the client has sent at least one full valid HTTP request, it schedules a "task" with a "thread dispatcher". The thread dispatcher <em>maintains a fixed pool of worker threads available to do client work</em> (by default, 4 threads). If a worker thread is available when a task is scheduled, the worker thread runs the task. The task has access to the channel, and can write back to the channel's output buffer. When <em>all worker threads are in use</em>, scheduled tasks will <em>wait in a queue</em> for a worker thread to become available.</p>
  </blockquote>
  
  <p>There doesn't seem to be much information on Stackoverflow either. From the question <a href="https://stackoverflow.com/questions/30065314/is-gunicorns-gthread-async-worker-analogous-to-waitress">"Is Gunicorn's gthread async worker analogous to Waitress?"</a>:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <hr>
  
  <p>These statements don't address the GIL (at least from my understanding) and it'd be great if someone could elaborate more on how worker threads work for Waitress. Thanks!</p>