Support returning app_iter from renderer. #1417
Merged
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.
Sets
response.app_iter = result
for renderer results which are not text, bytes or None.My motivating case here is that rendering very large json responses can lead to 'memory leaks' where python is unable to release the space required for the large string back to the OS. This causes process size to increase as it allocates first 100MB for a large json response, then later for a slightly larger json response, it allocates say 105MB, then 115MB... (These allocations are visible in /proc//smaps.)
My hope is that by using using json serializer that returns an iterable these large string allocations will not be required: