patch from @asenchi fixing broken pipes. thanks!

This commit is contained in:
benoitc 2010-01-18 13:36:42 +01:00
parent a5379e67fa
commit 6f5b16ab91
2 changed files with 11 additions and 5 deletions

View File

@ -122,7 +122,7 @@ class Arbiter(object):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_sockopts(sock)
sock.bind(address)
sock.listen(1024)
sock.listen(2048)
return sock
def set_sockopts(self, sock):

View File

@ -68,11 +68,17 @@ def read_partial(sock, length):
return data
def write(sock, data):
for i in range(2):
buf = ""
buf += data
while buf:
try:
return sock.send(data)
bytes = sock.send(buf)
buf = buf[bytes:]
return bytes
except socket.error, e:
if i == 0:
if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN):
break
elif e[0] in (errno.EPIPE,):
continue
raise
@ -116,4 +122,4 @@ def http_date(timestamp=None):
weekdayname[wd],
day, monthname[month], year,
hh, mm, ss)
return s
return s