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,19 +104,12 @@ def read_partial(sock, length):
return data return data
def write(sock, data): def write(sock, data):
buf = "" try:
buf += data sock.sendall(data)
while buf: except:
try: if e[0] not in (errno.EWOULDBLOCK, errno.EAGAIN):
bytes = sock.send(buf) pass
if bytes < len(buf): raise
buf = buf[bytes:]
continue
return len(data)
except socket.error, e:
if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN):
break
raise
def write_nonblock(sock, data): def write_nonblock(sock, data):
timeout = sock.gettimeout() timeout = sock.gettimeout()