Close WSGI producer at Content-Length completion - #179
Open
kentbull wants to merge 1 commit into
Open
Conversation
Treat exact Content-Length emission as successful response completion while closing and forgetting the suspended iterator. This runs generator cleanup without resuming a faulty or nonterminating producer beyond the framed body.
This was referenced Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Close and forget the suspended WSGI response iterator when emitted bytes reach the declared Content-Length. Keep the response successfully ended without advancing the producer again.
Why
HIO already treats the framed body as complete, but retained the suspended generator and its application-owned resources. Closing after the current
next()returns runs generator cleanup without recurrently servicing a faulty or nonterminating producer beyond the HTTP body boundary.Fixes #178.
This is the target-native upstream port of GLEIF-IT#18.
Boundary
This PR owns exact Content-Length completion and cleanup of the currently stored iterator only. Universal application-returned-iterable ownership, abort/failure settlement, transport drain policy, and TLS shutdown remain separate work.