From: Ben Darnell Date: Sun, 25 May 2014 20:34:41 +0000 (-0400) Subject: Merge remote-tracking branch 'methane/write-buffer-size' X-Git-Tag: v4.0.0b1~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4de52a52d9145881aca7cfd31932fbe010e3da50;p=thirdparty%2Ftornado.git Merge remote-tracking branch 'methane/write-buffer-size' Conflicts: tornado/iostream.py --- 4de52a52d9145881aca7cfd31932fbe010e3da50 diff --cc tornado/iostream.py index cad8a6f73,e0b815033..c16202a31 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@@ -72,15 -67,11 +72,20 @@@ class StreamClosedError(IOError) pass +class UnsatisfiableReadError(Exception): + """Exception raised when a read cannot be satisfied. + + Raised by ``read_until`` and ``read_until_regex`` with a ``max_bytes`` + argument. + """ + pass + + + class StreamBufferFullError(IOError): + """Exception raised by `IOStream.write` method when write buffer is full. + """ + + class BaseIOStream(object): """A utility class to write to and read from a non-blocking file or socket. @@@ -100,13 -86,11 +105,14 @@@ `read_from_fd`, and optionally `get_fd_error`. """ def __init__(self, io_loop=None, max_buffer_size=None, - read_chunk_size=None): - read_chunk_size=4096, max_write_buffer_size=None): ++ read_chunk_size=None, max_write_buffer_size=None): self.io_loop = io_loop or ioloop.IOLoop.current() self.max_buffer_size = max_buffer_size or 104857600 + # A chunk size that is too close to max_buffer_size can cause + # spurious failures. + self.read_chunk_size = min(read_chunk_size or 65536, + self.max_buffer_size // 2) + self.max_write_buffer_size = max_write_buffer_size - self.read_chunk_size = read_chunk_size self.error = None self._read_buffer = collections.deque() self._write_buffer = collections.deque()