asyncio: Fix @coroutine to recognize CoroWrapper (issue #25647)

Patch by Vladimir Rutsky.
This commit is contained in:
Yury Selivanov 2016-03-02 10:49:16 -05:00
parent 0c6a34409e
commit dce63234c5
2 changed files with 26 additions and 1 deletions

View file

@ -204,7 +204,8 @@ def coroutine(func):
@functools.wraps(func)
def coro(*args, **kw):
res = func(*args, **kw)
if isinstance(res, futures.Future) or inspect.isgenerator(res):
if isinstance(res, futures.Future) or inspect.isgenerator(res) or \
isinstance(res, CoroWrapper):
res = yield from res
elif _AwaitableABC is not None:
# If 'func' returns an Awaitable (new in 3.5) we