Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup.
(Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.)
+* :func:`asyncio.iscoroutine` now returns ``False`` for generators as
+ :mod:`asyncio` does not support legacy generator-based coroutines.
+ (Contributed by Kumar Aditya in :gh:`102748`.)
+
inspect
-------
# Prioritize native coroutine check to speed-up
# asyncio.iscoroutine.
-_COROUTINE_TYPES = (types.CoroutineType, types.GeneratorType,
- collections.abc.Coroutine)
+_COROUTINE_TYPES = (types.CoroutineType, collections.abc.Coroutine)
_iscoroutine_typecache = set()
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
+ def test_iscoroutine_generator(self):
+ def foo(): yield
+
+ self.assertFalse(asyncio.iscoroutine(foo()))
+
+
def test_iscoroutinefunction(self):
async def foo(): pass
self.assertTrue(asyncio.iscoroutinefunction(foo))
--- /dev/null
+:func:`asyncio.iscoroutine` now returns ``False`` for generators as
+:mod:`asyncio` does not support legacy generator-based coroutines.
+Patch by Kumar Aditya.