diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/asyncio-task.rst | 60 | ||||
-rw-r--r-- | Doc/library/collections.abc.rst | 4 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 2 | ||||
-rw-r--r-- | Doc/whatsnew/3.11.rst | 10 |
4 files changed, 12 insertions, 64 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index bbdef33..44ec3cc 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -148,9 +148,6 @@ other coroutines:: * a *coroutine object*: an object returned by calling a *coroutine function*. -asyncio also supports legacy :ref:`generator-based -<asyncio_generator_based_coro>` coroutines. - .. rubric:: Tasks @@ -1042,60 +1039,3 @@ Task Object in the :func:`repr` output of a task object. .. versionadded:: 3.8 - - -.. _asyncio_generator_based_coro: - -Generator-based Coroutines -========================== - -.. note:: - - Support for generator-based coroutines is **deprecated** and - is scheduled for removal in Python 3.10. - -Generator-based coroutines predate async/await syntax. They are -Python generators that use ``yield from`` expressions to await -on Futures and other coroutines. - -Generator-based coroutines should be decorated with -:func:`@asyncio.coroutine <asyncio.coroutine>`, although this is not -enforced. - - -.. decorator:: coroutine - - Decorator to mark generator-based coroutines. - - This decorator enables legacy generator-based coroutines to be - compatible with async/await code:: - - @asyncio.coroutine - def old_style_coroutine(): - yield from asyncio.sleep(1) - - async def main(): - await old_style_coroutine() - - This decorator should not be used for :keyword:`async def` - coroutines. - - .. deprecated-removed:: 3.8 3.10 - - Use :keyword:`async def` instead. - -.. function:: iscoroutine(obj) - - Return ``True`` if *obj* is a :ref:`coroutine object <coroutine>`. - - This method is different from :func:`inspect.iscoroutine` because - it returns ``True`` for generator-based coroutines. - -.. function:: iscoroutinefunction(func) - - Return ``True`` if *func* is a :ref:`coroutine function - <coroutine>`. - - This method is different from :func:`inspect.iscoroutinefunction` - because it returns ``True`` for generator-based coroutine functions - decorated with :func:`@coroutine <coroutine>`. diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst index 2345e78..924d0b5 100644 --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -198,7 +198,7 @@ ABC Inherits from Abstract Methods Mixin .. note:: In CPython, generator-based coroutines (generators decorated with - :func:`types.coroutine` or :func:`asyncio.coroutine`) are + :func:`types.coroutine`) are *awaitables*, even though they do not have an :meth:`__await__` method. Using ``isinstance(gencoro, Awaitable)`` for them will return ``False``. Use :func:`inspect.isawaitable` to detect them. @@ -216,7 +216,7 @@ ABC Inherits from Abstract Methods Mixin .. note:: In CPython, generator-based coroutines (generators decorated with - :func:`types.coroutine` or :func:`asyncio.coroutine`) are + :func:`types.coroutine`) are *awaitables*, even though they do not have an :meth:`__await__` method. Using ``isinstance(gencoro, Coroutine)`` for them will return ``False``. Use :func:`inspect.isawaitable` to detect them. diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index eefdc3d..2f8ed70 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2714,7 +2714,7 @@ are awaitable. .. note:: The :term:`generator iterator` objects returned from generators - decorated with :func:`types.coroutine` or :func:`asyncio.coroutine` + decorated with :func:`types.coroutine` are also awaitable, but they do not implement :meth:`__await__`. .. method:: object.__await__(self) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 8e3d5f3..94d8bef 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -171,7 +171,15 @@ Deprecated Removed ======= - +* The :func:`@asyncio.coroutine <asyncio.coroutine>` :term:`decorator` enabling + legacy generator-based coroutines to be compatible with async/await code. + The function has been deprecated since Python 3.8 and the removal was + initially scheduled for Python 3.10. Use :keyword:`async def` instead. + (Contributed by Illia Volochii in :issue:`43216`.) + +* :class:`asyncio.coroutines.CoroWrapper` used for wrapping legacy + generator-based coroutine objects in the debug mode. + (Contributed by Illia Volochii in :issue:`43216`.) Porting to Python 3.11 ====================== |