From: Ben Darnell Date: Mon, 11 Oct 2010 18:20:25 +0000 (-0700) Subject: Limit the amount of data sent to socket.send at a time (for windows). X-Git-Tag: v1.2.0~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fffe5a8c738a43821c993fab2693437f229e6c1;p=thirdparty%2Ftornado.git Limit the amount of data sent to socket.send at a time (for windows). Closes #97. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index c18f8f1d2..0a4fd8f75 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -278,7 +278,11 @@ class IOStream(object): def _handle_write(self): while self._write_buffer: try: - num_bytes = self.socket.send(self._write_buffer) + # On windows, socket.send blows up if given a write buffer + # that's too large, instead of just returning the number + # of bytes it was able to process. + temp_write_buffer = self._write_buffer[:128 * 1024] + num_bytes = self.socket.send(temp_write_buffer) self._write_buffer = self._write_buffer[num_bytes:] except socket.error, e: if e.args[0] in (errno.EWOULDBLOCK, errno.EAGAIN):