From: Waldecir Santos Date: Wed, 17 Apr 2013 18:00:09 +0000 (-0300) Subject: Expose IOStream's max_buffer_size, so we can set it in TCPServer and others. X-Git-Tag: v3.1.0~76^2~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ec7dfe2dc50f5d1c75f8f8daea103eaaac29be0;p=thirdparty%2Ftornado.git Expose IOStream's max_buffer_size, so we can set it in TCPServer and others. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index 16b0fac1a..b86d3540e 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -64,10 +64,10 @@ class BaseIOStream(object): Subclasses must implement `fileno`, `close_fd`, `write_to_fd`, `read_from_fd`, and optionally `get_fd_error`. """ - def __init__(self, io_loop=None, max_buffer_size=104857600, + def __init__(self, io_loop=None, max_buffer_size=None, read_chunk_size=4096): self.io_loop = io_loop or ioloop.IOLoop.current() - self.max_buffer_size = max_buffer_size + self.max_buffer_size = 104857600 or max_buffer_size self.read_chunk_size = read_chunk_size self.error = None self._read_buffer = collections.deque() diff --git a/tornado/tcpserver.py b/tornado/tcpserver.py index fbd9c63d3..d3ed01c68 100644 --- a/tornado/tcpserver.py +++ b/tornado/tcpserver.py @@ -78,12 +78,13 @@ class TCPServer(object): your listening sockets in some way other than `~tornado.netutil.bind_sockets`. """ - def __init__(self, io_loop=None, ssl_options=None): + def __init__(self, io_loop=None, ssl_options=None, max_buffer_size=None): self.io_loop = io_loop self.ssl_options = ssl_options self._sockets = {} # fd -> socket object self._pending_sockets = [] self._started = False + self.max_buffer_size = max_buffer_size # Verify the SSL options. Otherwise we don't get errors until clients # connect. This doesn't verify that the keys are legitimate, but @@ -222,9 +223,9 @@ class TCPServer(object): raise try: if self.ssl_options is not None: - stream = SSLIOStream(connection, io_loop=self.io_loop) + stream = SSLIOStream(connection, io_loop=self.io_loop, max_buffer_size=self.max_buffer_size) else: - stream = IOStream(connection, io_loop=self.io_loop) + stream = IOStream(connection, io_loop=self.io_loop, max_buffer_size=self.max_buffer_size) self.handle_stream(stream, address) except Exception: app_log.error("Error in connection callback", exc_info=True)