]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix `IOStream' when callback function return `Future' and has 1142/head
authorWEI Zhicheng <zhicheng@opensourceforge.net>
Thu, 7 Aug 2014 17:49:39 +0000 (01:49 +0800)
committerWEI Zhicheng <zhicheng@opensourceforge.net>
Thu, 7 Aug 2014 17:49:39 +0000 (01:49 +0800)
`Exception' will silence ignore

tornado/iostream.py

index 059e4e93f663abd8382c1b0103a1f4c86204eb6b..3726a768e7449f2dffa3b06483dbdd48a7ddc5d2 100644 (file)
@@ -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