From 87fa80c9ebd6eda8c1596bed738bdf4fb8df1e67 Mon Sep 17 00:00:00 2001 From: WEI Zhicheng Date: Fri, 8 Aug 2014 01:49:39 +0800 Subject: [PATCH] Fix `IOStream' when callback function return `Future' and has `Exception' will silence ignore --- tornado/iostream.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tornado/iostream.py b/tornado/iostream.py index 3ebcd586..99c681d8 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -505,7 +505,7 @@ class BaseIOStream(object): def wrapper(): self._pending_callbacks -= 1 try: - callback(*args) + return callback(*args) except Exception: app_log.error("Uncaught exception, closing connection.", exc_info=True) @@ -517,7 +517,8 @@ class BaseIOStream(object): # Re-raise the exception so that IOLoop.handle_callback_exception # can see it and log the error raise - self._maybe_add_error_listener() + finally: + self._maybe_add_error_listener() # We schedule callbacks to be run on the next IOLoop iteration # rather than running them directly for several reasons: # * Prevents unbounded stack growth when a callback calls an