added test for api.timeout that checks no references to the error object were leaked
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
from __future__ import with_statement
|
||||
import unittest
|
||||
import weakref
|
||||
import time
|
||||
from eventlet.api import sleep, timeout, TimeoutError
|
||||
DELAY = 0.01
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
@@ -64,6 +68,14 @@ class Test(unittest.TestCase):
|
||||
delta = (time.time()-start)
|
||||
assert delta<XDELAY*2, delta
|
||||
|
||||
def test_ref(self):
|
||||
err = Error()
|
||||
err_ref = weakref.ref(err)
|
||||
with timeout(DELAY*2, err):
|
||||
sleep(DELAY)
|
||||
del err
|
||||
assert not err_ref(), repr(err_ref())
|
||||
|
||||
def test_nested_timeout(self):
|
||||
with timeout(DELAY, None):
|
||||
with timeout(DELAY*2, None):
|
||||
|
Reference in New Issue
Block a user