merge
This commit is contained in:
@@ -281,24 +281,36 @@ class GreenSocket(object):
|
|||||||
fd = self.fd
|
fd = self.fd
|
||||||
if self.act_non_blocking:
|
if self.act_non_blocking:
|
||||||
return fd.send(data, flags)
|
return fd.send(data, flags)
|
||||||
try:
|
|
||||||
|
# XXX: need to deal with the exceptions that could be raised if the
|
||||||
|
# buffer is full (specifically the try/except below)
|
||||||
|
|
||||||
|
# need to test all of the conditions
|
||||||
|
|
||||||
|
# blocking socket behavior - sends all, blocks if the buffer is full
|
||||||
|
total_sent = 0
|
||||||
|
len_data = len(data)
|
||||||
|
|
||||||
|
while 1:
|
||||||
|
try:
|
||||||
|
total_sent += fd.send(data[total_sent:], flags)
|
||||||
|
except socket.error, e:
|
||||||
|
if e[0] not in SOCKET_BLOCKING:
|
||||||
|
raise
|
||||||
|
|
||||||
|
if total_sent == len_data:
|
||||||
|
break
|
||||||
|
|
||||||
trampoline(self.fd, write=True, timeout=self.gettimeout(),
|
trampoline(self.fd, write=True, timeout=self.gettimeout(),
|
||||||
timeout_exc=socket.timeout("timed out"))
|
timeout_exc=socket.timeout("timed out"))
|
||||||
return fd.send(data, flags)
|
|
||||||
except socket.error, e:
|
return total_sent
|
||||||
if e[0] in SOCKET_BLOCKING:
|
|
||||||
return 0
|
|
||||||
raise
|
|
||||||
|
|
||||||
def sendall(self, data, flags=0):
|
def sendall(self, data, flags=0):
|
||||||
fd = self.fd
|
fd = self.fd
|
||||||
tail = self.send(data, flags)
|
tail = self.send(data, flags)
|
||||||
len_data = len(data)
|
len_data = len(data)
|
||||||
while tail < len_data:
|
while tail < len_data:
|
||||||
trampoline(fd,
|
|
||||||
write=True,
|
|
||||||
timeout=self.timeout,
|
|
||||||
timeout_exc=socket.timeout("timed out"))
|
|
||||||
tail += self.send(data[tail:], flags)
|
tail += self.send(data[tail:], flags)
|
||||||
|
|
||||||
def sendto(self, *args):
|
def sendto(self, *args):
|
||||||
|
@@ -160,6 +160,7 @@ class TestGreenIo(LimitedTestCase):
|
|||||||
def server():
|
def server():
|
||||||
# accept the connection in another greenlet
|
# accept the connection in another greenlet
|
||||||
sock, addr = listener.accept()
|
sock, addr = listener.accept()
|
||||||
|
bufsized(sock, 1)
|
||||||
|
|
||||||
eventlet.sleep(.5)
|
eventlet.sleep(.5)
|
||||||
|
|
||||||
@@ -171,9 +172,10 @@ class TestGreenIo(LimitedTestCase):
|
|||||||
client.settimeout(0.1)
|
client.settimeout(0.1)
|
||||||
|
|
||||||
client.connect(addr)
|
client.connect(addr)
|
||||||
|
bufsized(client, 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
msg = "A"*(8*1024*1024)
|
msg = "A"*min_buf_size()
|
||||||
|
|
||||||
# want to exceed the size of the OS buffer so it'll block
|
# want to exceed the size of the OS buffer so it'll block
|
||||||
for x in range(10):
|
for x in range(10):
|
||||||
|
Reference in New Issue
Block a user