You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asyncio.iscoroutine() documentation is wrong #78983
The documentation states that "This method is different from inspect.iscoroutine() because it returns True for generator-based coroutines decorated with @coroutine."
It seems to be wrong, a method written as follow:
deftest(): yield1
will be evaluated as a coroutine by asyncio.iscoroutine(), even if not decorated. The old doc stated "Return True if obj is a coroutine object, which may be based on a generator or an async def coroutine.", which seems more correct.
Thanks for the report. I believe this was done as part asyncio docs overhaul and I am adding Yury here. The current docs link to #coroutine from asyncio.iscoroutine whereas the previous docs had the definition inline. I think this is clarified in #awaitables section but takes a round-trip and it's not in #coroutines section which is linked in asyncio.iscoroutine. The below is present in important note in #awaitables and may be this can be added to #coroutine too so that it's not last? Suggestions welcome
asyncio also supports legacy generator-based coroutines
I would suggest below for #coroutines :
Coroutines declared with async/await syntax is the preferred way of writing asyncio applications but asyncio also supports legacy generator-based coroutines.
I'll make a simple fix for the asyncio.coroutine decorator docs.
I would suggest below for #coroutines :
> Coroutines declared with async/await syntax is the preferred way of writing asyncio applications but asyncio also supports legacy generator-based coroutines.
I don't want to further emphasize generator-based coroutines beyond how they are covered right now. We'll drop support for them in a just a couple of versions anyways.
Activity
abcd commentedon Sep 25, 2018
The documentation states that "This method is different from inspect.iscoroutine() because it returns True for generator-based coroutines decorated with @coroutine."
It seems to be wrong, a method written as follow:
will be evaluated as a coroutine by asyncio.iscoroutine(), even if not decorated. The old doc stated "Return True if obj is a coroutine object, which may be based on a generator or an async def coroutine.", which seems more correct.
tirkarthi commentedon Sep 26, 2018
Thanks for the report. I believe this was done as part asyncio docs overhaul and I am adding Yury here. The current docs link to #coroutine from asyncio.iscoroutine whereas the previous docs had the definition inline. I think this is clarified in #awaitables section but takes a round-trip and it's not in #coroutines section which is linked in asyncio.iscoroutine. The below is present in important note in #awaitables and may be this can be added to #coroutine too so that it's not last? Suggestions welcome
I would suggest below for #coroutines :
Thanks
1st1 commentedon Sep 27, 2018
I'll make a simple fix for the asyncio.coroutine decorator docs.
I don't want to further emphasize generator-based coroutines beyond how they are covered right now. We'll drop support for them in a just a couple of versions anyways.
1st1 commentedon Sep 27, 2018
New changeset 59ee5b1 by Yury Selivanov in branch 'master':
bpo-34802: Fix asyncio.iscoroutine() docs (GH-9611)
59ee5b1
miss-islington commentedon Sep 27, 2018
New changeset 85ccedc by Miss Islington (bot) in branch '3.7':
bpo-34802: Fix asyncio.iscoroutine() docs (GH-9611)
85ccedc
abcd commentedon Sep 27, 2018
I think it's much clearer