Catches and logs to the application log exceptions raised by each callback. This
more or less mirrors what concurrent.futures.Future does.
from tornado.stack_context import ExceptionStackContext, wrap
from tornado.util import raise_exc_info, ArgReplacer
+from tornado.log import app_log
try:
from concurrent import futures
def _set_done(self):
self._done = True
for cb in self._callbacks:
- # TODO: error handling
- cb(self)
+ try:
+ cb(self)
+ except Exception:
+ app_log.exception('exception calling callback %r for %r',
+ cb, self)
self._callbacks = None
TracebackFuture = Future