use sendall instead of our loop

This commit is contained in:
benoitc 2010-02-25 15:43:33 +01:00
parent 9c60695713
commit 1126579963

View File

@ -104,18 +104,11 @@ def read_partial(sock, length):
return data return data
def write(sock, data): def write(sock, data):
buf = ""
buf += data
while buf:
try: try:
bytes = sock.send(buf) sock.sendall(data)
if bytes < len(buf): except:
buf = buf[bytes:] if e[0] not in (errno.EWOULDBLOCK, errno.EAGAIN):
continue pass
return len(data)
except socket.error, e:
if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN):
break
raise raise
def write_nonblock(sock, data): def write_nonblock(sock, data):