This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Return of asyncio.coroutine from asyncio.coroutine doesn't work with enabled asyncio debug
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, python-dev, vrutsky, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2015-11-17 12:05 by vrutsky, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_return_of_coro_from_coro.diff vrutsky, 2015-11-17 12:05 Fix this issue + adds test for it review
Messages (3)
msg254799 - (view) Author: Vladimir Rutsky (vrutsky) * Date: 2015-11-17 12:05
Return of @asyncio.coroutine-wrapped coroutine object from @asyncio.coroutine-wrapped coroutine fails if asyncio debug is enabled.

Consider following example:

@asyncio.coroutine
def outer_coro():
    @asyncio.coroutine
    def inner_coro():
        return 1

    return g()

result = loop.run_until_complete(outer_coro())

If debug is disabled result will be 1, if debug is enabled, result will be CoroWrapper object.

This issue is discussed on asyncio mailing list: https://groups.google.com/forum/?fromgroups#!topic/python-tulip/YFfFxftxxDc

Complete example to reproduce this problem is here: https://gist.github.com/rutsky/c72be2edeb1c8256d680

Attaching patch for Python 3.4 branch that fixes this issue and add test for this bug.

This issue is not reproduced in Python 3.5, because CoroWrapper is awaitable in Python 3.5 (and in Python 3.4 CoroWrapper is not future or generator).
msg261115 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-02 15:49
New changeset fd21f162e377 by Yury Selivanov in branch '3.5':
asyncio: Fix @coroutine to recognize CoroWrapper (issue #25647)
https://hg.python.org/cpython/rev/fd21f162e377

New changeset e3aee2f16937 by Yury Selivanov in branch 'default':
Merge 3.5 (issue #25647)
https://hg.python.org/cpython/rev/e3aee2f16937
msg261116 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-03-02 15:51
Vladimir, thanks for the patch!
History
Date User Action Args
2022-04-11 14:58:23adminsetgithub: 69833
2016-03-02 15:51:17yselivanovsetstatus: open -> closed
type: behavior
messages: + msg261116

resolution: fixed
stage: resolved
2016-03-02 15:49:47python-devsetnosy: + python-dev
messages: + msg261115
2015-11-17 12:06:10vrutskysettitle: Return of asyncio.coroutine from asyncio.coroutine doesn't work in with enabled debug -> Return of asyncio.coroutine from asyncio.coroutine doesn't work with enabled asyncio debug
2015-11-17 12:05:47vrutskysettitle: Return of asyncio.coroutine from asyncio.coroutine don't work in with enabled debug -> Return of asyncio.coroutine from asyncio.coroutine doesn't work in with enabled debug
2015-11-17 12:05:09vrutskycreate