From b8e44661464bd2e192322acbe73d08c83f4a1383 Mon Sep 17 00:00:00 2001 From: Andrew Grigorev Date: Thu, 24 May 2012 16:53:51 +0400 Subject: [PATCH] Split large chunks of data in IOStream.write. Closes #515. --- tornado/iostream.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tornado/iostream.py b/tornado/iostream.py index f8fadf68..62f31fdc 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -192,7 +192,11 @@ class IOStream(object): if data: # We use bool(_write_buffer) as a proxy for write_buffer_size>0, # so never put empty strings in the buffer. - self._write_buffer.append(data) + if len(data) > 128*1024: + for i in range(0, len(data), 128*1024): + self._write_buffer.append(data[i:i+128*1024]) + else: + self._write_buffer.append(data) self._write_callback = stack_context.wrap(callback) self._handle_write() if self._write_buffer: