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

View File

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