From 1126579963ed02f88a9aad6ba7d5f424edb14d61 Mon Sep 17 00:00:00 2001 From: benoitc Date: Thu, 25 Feb 2010 15:43:33 +0100 Subject: [PATCH] use sendall instead of our loop --- gunicorn/util.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/gunicorn/util.py b/gunicorn/util.py index 501d1e3c..062e5175 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -104,19 +104,12 @@ def read_partial(sock, length): return data def write(sock, data): - buf = "" - buf += data - while buf: - try: - bytes = sock.send(buf) - if bytes < len(buf): - buf = buf[bytes:] - continue - return len(data) - except socket.error, e: - if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN): - break - raise + try: + sock.sendall(data) + except: + if e[0] not in (errno.EWOULDBLOCK, errno.EAGAIN): + pass + raise def write_nonblock(sock, data): timeout = sock.gettimeout()