diff --git a/eventlet/greenio/base.py b/eventlet/greenio/base.py index fc9871f..634304a 100644 --- a/eventlet/greenio/base.py +++ b/eventlet/greenio/base.py @@ -359,28 +359,20 @@ class GreenSocket(object): if self.act_non_blocking: return send_method(data, *args) - # blocking socket behavior - sends all, blocks if the buffer is full - total_sent = 0 - len_data = len(data) while 1: try: - total_sent += send_method(data[total_sent:], *args) + return send_method(data, *args) except socket.error as e: eno = get_errno(e) if eno == errno.ENOTCONN or eno not in SOCKET_BLOCKING: raise - if total_sent == len_data: - break - try: self._trampoline(self.fd, write=True, timeout=self.gettimeout(), timeout_exc=socket.timeout("timed out")) except IOClosed: raise socket.error(errno.ECONNRESET, 'Connection closed by another thread') - return total_sent - def send(self, data, flags=0): return self._send_loop(self.fd.send, data, flags) diff --git a/tests/greenio_test.py b/tests/greenio_test.py index fdd2ac1..7b0ff7c 100644 --- a/tests/greenio_test.py +++ b/tests/greenio_test.py @@ -818,7 +818,14 @@ class TestGreenIoLong(tests.LimitedTestCase): client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(('127.0.0.1', listener.getsockname()[1])) bufsized(client, size=sendsize) - client.sendall(b'*' * sendsize) + + # Split into multiple chunks so that we can wait a little + # every iteration which allows both readers to queue and + # recv some data when we actually send it. + for i in range(20): + eventlet.sleep(0.001) + client.sendall(b'*' * (sendsize // 20)) + client.close() server_coro.wait() listener.close()