Skip to content

Commit

Permalink
Merge 16e63f3 into 8d8b35f
Browse files Browse the repository at this point in the history
  • Loading branch information
cdsboy committed Aug 29, 2019
2 parents 8d8b35f + 16e63f3 commit 574ec13
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tornado_json/schema.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 574ec13

Please sign in to comment.