to result in timeouts instead of making wait() re-throw the exception.
Add a test to verify that this works.
TEST_MODULES = [
'tornado.httputil.doctests',
- 'tornado.test.stack_context_test',
'tornado.test.ioloop_test',
+ 'tornado.test.stack_context_test',
+ 'tornado.test.testing_test',
]
def all():
--- /dev/null
+#!/usr/bin/env python
+import unittest
+from tornado.testing import AsyncTestCase, LogTrapTestCase
+
+class AsyncTestCaseTest(AsyncTestCase, LogTrapTestCase):
+ def test_exception_in_callback(self):
+ self.io_loop.add_callback(lambda: 1/0)
+ try:
+ self.wait()
+ self.fail("did not get expected exception")
+ except ZeroDivisionError:
+ pass
+
+if __name__ == '__main__':
+ unittest.main
from cStringIO import StringIO
from tornado.httpclient import AsyncHTTPClient
from tornado.httpserver import HTTPServer
-from tornado.stack_context import StackContext
+from tornado.stack_context import StackContext, NullContext
import contextlib
import functools
import logging
self.io_loop.add_timeout(time.time() + timeout, timeout_func)
while True:
self.__running = True
- self.io_loop.start()
+ with NullContext():
+ # Wipe out the StackContext that was established in
+ # self.run() so that all callbacks executed inside the
+ # IOLoop will re-run it.
+ self.io_loop.start()
if (self.__failure is not None or
condition is None or condition()):
break