mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
use sendall instead of our loop
This commit is contained in:
parent
9c60695713
commit
1126579963
@ -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()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user