]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Recognize other yieldables in web.asynchronous.
authorBen Darnell <ben@bendarnell.com>
Sun, 4 Oct 2015 00:57:23 +0000 (20:57 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 4 Oct 2015 02:28:15 +0000 (22:28 -0400)
Disallow non-None results.

tornado/test/web_test.py
tornado/web.py

index 9cb64afd5f3e8d3ce9cb99b6fd5ff3dc0148179f..fe7e4c1bf8eb42452987efd7727e910abaf7b26b 100644 (file)
@@ -574,8 +574,8 @@ class RedirectHandler(RequestHandler):
 
 
 class EmptyFlushCallbackHandler(RequestHandler):
-    @gen.engine
     @asynchronous
+    @gen.engine
     def get(self):
         # Ensure that the flush callback is run whether or not there
         # was any output.  The gen.Task and direct yield forms are
index f6ae767b07de85decf212199aa0069eef7961751..513af6f66e43c3e8718c0c106d04dae2666e20db 100644 (file)
@@ -81,7 +81,7 @@ import traceback
 import types
 from io import BytesIO
 
-from tornado.concurrent import Future, is_future
+from tornado.concurrent import Future
 from tornado import escape
 from tornado import gen
 from tornado import httputil
@@ -1577,9 +1577,12 @@ def asynchronous(method):
     .. testoutput::
        :hide:
 
-    .. versionadded:: 3.1
+    .. versionchanged:: 3.1
        The ability to use ``@gen.coroutine`` without ``@asynchronous``.
 
+    .. versionchanged:: 4.3 Returning anything but ``None`` or a
+       yieldable object from a method decorated with ``@asynchronous``
+       is an error. Such return values were previously ignored silently.
     """
     # Delay the IOLoop import because it's not available on app engine.
     from tornado.ioloop import IOLoop
@@ -1590,7 +1593,8 @@ def asynchronous(method):
         with stack_context.ExceptionStackContext(
                 self._stack_context_handle_exception):
             result = method(self, *args, **kwargs)
-            if is_future(result):
+            if result is not None:
+                result = gen.convert_yielded(result)
                 # If @asynchronous is used with @gen.coroutine, (but
                 # not @gen.engine), we can automatically finish the
                 # request when the future resolves.  Additionally,