Tweaked the send_timeout test a little, mostly just so I understand it. Clearing exc_info right after squelching exceptions in hubs.

This commit is contained in:
Ryan Williams
2010-02-24 21:51:07 -05:00
parent 5ef9bd1601
commit ee71f87f74
2 changed files with 10 additions and 10 deletions

View File

@@ -102,6 +102,7 @@ class BaseHub(object):
switch_out()
except:
self.squelch_generic_exception(sys.exc_info())
sys.exc_clear()
if self.greenlet.dead:
self.greenlet = greenlet.greenlet(self.run)
try:
@@ -251,6 +252,7 @@ class BaseHub(object):
raise
except:
self.squelch_timer_exception(timer, sys.exc_info())
sys.exc_clear()
finally:
self.timer_finished(timer)

View File

@@ -153,30 +153,27 @@ class TestGreenIo(LimitedTestCase):
gt.wait()
def test_send_timeout(self):
listener = greenio.GreenSocket(socket.socket())
listener.bind(('', 0))
listener.listen(50)
listener = bufsized(eventlet.listen(('', 0)))
def server():
# accept the connection in another greenlet
sock, addr = listener.accept()
sock = bufsized(sock)
eventlet.sleep(.5)
gt = eventlet.spawn(server)
addr = listener.getsockname()
client = greenio.GreenSocket(socket.socket())
client.settimeout(0.1)
client = bufsized(greenio.GreenSocket(socket.socket()))
client.connect(addr)
try:
msg = "A"*8192*1024
client.settimeout(0.00001)
msg = "A"*(100000) # large enough number to overwhelm most buffers
total_sent = 0
# 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 in a
# single send
for x in range(10):
total_sent += client.send(msg)
self.fail("socket.timeout not raised")
@@ -473,6 +470,7 @@ class TestGreenIo(LimitedTestCase):
gt.wait()
class TestGreenIoLong(LimitedTestCase):
TEST_TIMEOUT=10 # the test here might take a while depending on the OS
@skip_with_pyevent