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