Skip to content

Commit

Permalink
Merge commit 'f40d39b'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Sep 15, 2014
2 parents ca2cf40 + f40d39b commit f10e4a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tornado/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

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
Expand Down Expand Up @@ -173,8 +174,11 @@ def _check_done(self):
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
Expand Down
5 changes: 4 additions & 1 deletion tornado/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def final_callback(future):
raise ReturnValueIgnoredError(
"@gen.engine functions cannot return values: %r" %
(future.result(),))
future.add_done_callback(final_callback)
# The engine interface doesn't give us any way to return
# errors but to raise them into the stack context.
# Save the stack context here to use when the Future has resolved.
future.add_done_callback(stack_context.wrap(final_callback))
return wrapper


Expand Down

0 comments on commit f10e4a0

Please sign in to comment.