From: Ben Darnell Date: Sun, 4 Oct 2015 00:57:23 +0000 (-0400) Subject: Recognize other yieldables in web.asynchronous. X-Git-Tag: v4.3.0b1~8^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95a17c6c4bbadbca404281e568c712b97a64d811;p=thirdparty%2Ftornado.git Recognize other yieldables in web.asynchronous. Disallow non-None results. --- diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 9cb64afd5..fe7e4c1bf 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -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 diff --git a/tornado/web.py b/tornado/web.py index f6ae767b0..513af6f66 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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,