With a giant shout-out to Michael Merickel for all his hard work on the latest version of waitress.
- The send_bytes adjustment now defaults to 1 and is deprecated pending removal in a future release. It no longer changes how many bytes are placed into the socket, and instead determines how many bytes waitress should buffer before sending data to the client.
This change will increase interactivity for users of waitress and will increase how fast users will see the first byte returned from your WSGI application. Please report any adverse unintended side effects (I doubt there are any, but would love to hear them). See features below for the other change related to send_bytes.
- Add a new outbuf_high_watermark adjustment which is used to apply backpressure on the app_iter to avoid letting it spin faster than data can be written to the socket. This stabilizes responses that iterate quickly with a lot of data. This also avoids waitress from buffering too much of app_iter and filling the disk.
- Stop early and close the app_iter when attempting to write to a closed socket due to a client disconnect. This should notify a long-lived streaming response when a client hangs up. Previously waitress would iterate until the app_iter returned.
- Adjust the flush to output SO_SNDBUF bytes instead of whatever was set in the send_bytes adjustment. send_bytes now only controls how much waitress will buffer internally before flushing to the kernel, whereas previously it used to also throttle how much data was sent to the kernel. This change enables a streaming app_iter containing small chunks to still be flushed efficiently.
- When a client closes a socket unexpectedly there was potential for memory leaks in which data was written to the buffers after they were closed, causing them to reopen.
- Fix the queue depth warnings to only show when all threads are busy. This avoids spurious warnings that users were seeing. Users may still wish to increase the thread count from the default.
- Trigger the app_iter to close as part of shutdown. This will only be noticeable for users of the internal server api. In more typical operations the server will die before benefiting from these changes.
- Fix a bug in which a streaming app_iter may never cleanup data that has already been sent. This would cause buffers in waitress to grow without bounds. These buffers now properly rotate and release their data. (see related feature outbuf_high_watermark)
- Fix a bug in which non-seekable subclasses of io.IOBase would trigger an exception when passed to the wsgi.file_wrapper callback.
pip install waitress==1.3.0b0
On pypi: https://pypi.org/project/waitress/1.3.0b0/
Please give this a good test run with your test/production workloads. Unless I hear screams, I will likely release this as soon as this coming Monday!