Add write_buffer_size property and max_write_buffer_size limitation to iostream. #1000

Merged
merged 3 commits into from May 25, 2014

2 participants

@methane

In the case of chat application, slow client or TCP timeout may consume very large write buffer.
To write robust application, iostream should support limiting write buffer size.

@bdarnell bdarnell and 1 other commented on an outdated diff Mar 4, 2014
tornado/iostream.py
@@ -304,6 +315,11 @@ def writing(self):
"""Returns true if we are currently writing to the stream."""
return bool(self._write_buffer)
+ @property
@bdarnell
tornadoweb member
bdarnell added a line comment Mar 4, 2014

If this needs to be exposed publicly, I'd rather just make the attribute public instead of having both a semi-private attribute and a public read-only property.

It's odd that this is public but read_buffer_size is not. Do we need a way to inspect the buffer size here in addition to being able to try the write and catch the exception? Keep in mind that we already have another way to manage write buffer sizes via the write callback (although I agree that that is not always suitable and we need some way to detect a stream that is not making sufficient progress).

@methane
methane added a line comment Mar 4, 2014

I just added it for consistency with read_buffer_size.
My real use case is limiting write buffer size to avoid OOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@methane

I've removed write_buffer_size property.

@bdarnell bdarnell merged commit 753de8d into tornadoweb:master May 25, 2014

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment