diff --git a/tornado_json/schema.py b/tornado_json/schema.py index d60bffe..bbef971 100644 --- a/tornado_json/schema.py +++ b/tornado_json/schema.py @@ -7,6 +7,11 @@ from tornado_json.exceptions import APIError +try: + from asyncio import iscoroutine +except ImportError: + iscoroutine = lambda x: False + try: from tornado.concurrent import is_future except ImportError: @@ -159,8 +164,8 @@ def _wrapper(self, *args, **kwargs): # Call the requesthandler method output = rh_method(self, *args, **kwargs) # If the rh_method returned a Future a la `raise Return(value)` - # we grab the output. - if is_future(output): + # or a python 3 coroutine we grab the output. + if is_future(output) or iscoroutine(output): output = yield output # if output is empty, auto return the error 404.