From 797735403e28283fabdd87bd0158a527319bb5df Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 3 Oct 2022 15:27:29 -0700 Subject: [PATCH 1/8] GH-95913: Update what's new in 3.11 for asyncio --- Doc/whatsnew/3.11.rst | 45 ++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 19821e1b602994..76b409bad2e7a6 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -532,24 +532,43 @@ Improved Modules asyncio ------- -* Add raw datagram socket functions to the event loop: +* Added the :class:`~asyncio.TaskGroup` class, + an :ref:`asynchronous context manager ` + holding a group of tasks that will wait for all of them upon exit. + For new code this is recommended over using + :class:`~asyncio.create_task` and :func:`~asyncio.gather` directly. + (Contributed by Yury Seliganov and others in :gh:`90908`.) + +* Added :func:`~asyncio.timeout`, an asynchronous context manager for + setting a timeout on asynchronous operations For new code this is + recommended over using :func:`~asyncio.wait_for` directly. + (Contributed by Andrew Svetlov in :gh:`90927`.) + +* Added the :class:`~asyncio.Runner` class, which exposes the machinery + used by :func:`~asyncio.run`. + (Contributed by Andrew Svetlov in :gh:`91218`.) + +* Added the :class:`~asyncio.Barrier` class to the synchronization + primitives in the asyncio library, and the related + :exc:`~asyncio.BrokenBarrierError` exception. + (Contributed by Yves Duprat and Andrew Svetlov in :gh:`87518`.) + +* Added the :meth:`~asyncio.StreamWriter.start_tls` method for + upgrading existing stream-based connections to TLS. + (Contributed by Ian Good in :issue:`34975`.) + +* Added raw datagram socket functions to the event loop: :meth:`~asyncio.AbstractEventLoop.sock_sendto`, :meth:`~asyncio.AbstractEventLoop.sock_recvfrom` and :meth:`~asyncio.AbstractEventLoop.sock_recvfrom_into`. + These have implementations in :class:`~asyncio.SelectorEventLoop` and + :class:`~asyncio.ProactorEventLoop`. (Contributed by Alex Grönholm in :issue:`46805`.) -* Add :meth:`~asyncio.streams.StreamWriter.start_tls` method for upgrading - existing stream-based connections to TLS. (Contributed by Ian Good in - :issue:`34975`.) - -* Add :class:`~asyncio.Barrier` class to the synchronization primitives of - the asyncio library. (Contributed by Yves Duprat and Andrew Svetlov in - :gh:`87518`.) - -* Add :class:`~asyncio.TaskGroup` class, - an :ref:`asynchronous context manager ` - holding a group of tasks that will wait for all of them upon exit. - (Contributed by Yury Seliganov and others.) +* Added :meth:`~asyncio.Task.cancelling` and + :meth:`~asyncio.Task.uncancel` methods to :class:`~asyncio.Task`. + These are primarily intended for internal use, + notably by :class:`~asyncio.TaskGroup`. contextlib ---------- From df41e7105082f0cec15bb8d2aabf82d62b5710bf Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 3 Oct 2022 17:25:21 -0700 Subject: [PATCH 2/8] Trailing ws --- Doc/whatsnew/3.11.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 76b409bad2e7a6..10ab18b498d8b8 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -540,7 +540,7 @@ asyncio (Contributed by Yury Seliganov and others in :gh:`90908`.) * Added :func:`~asyncio.timeout`, an asynchronous context manager for - setting a timeout on asynchronous operations For new code this is + setting a timeout on asynchronous operations For new code this is recommended over using :func:`~asyncio.wait_for` directly. (Contributed by Andrew Svetlov in :gh:`90927`.) From a2b292f8653ec19152dce76d6859aa30ec41417b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Oct 2022 08:02:28 -0700 Subject: [PATCH 3/8] Fixes from Kumar Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- Doc/whatsnew/3.11.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 10ab18b498d8b8..728f58c57d8c4b 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -536,11 +536,11 @@ asyncio an :ref:`asynchronous context manager ` holding a group of tasks that will wait for all of them upon exit. For new code this is recommended over using - :class:`~asyncio.create_task` and :func:`~asyncio.gather` directly. + :func:`~asyncio.create_task` and :func:`~asyncio.gather` directly. (Contributed by Yury Seliganov and others in :gh:`90908`.) * Added :func:`~asyncio.timeout`, an asynchronous context manager for - setting a timeout on asynchronous operations For new code this is + setting a timeout on asynchronous operations. For new code this is recommended over using :func:`~asyncio.wait_for` directly. (Contributed by Andrew Svetlov in :gh:`90927`.) @@ -558,9 +558,9 @@ asyncio (Contributed by Ian Good in :issue:`34975`.) * Added raw datagram socket functions to the event loop: - :meth:`~asyncio.AbstractEventLoop.sock_sendto`, - :meth:`~asyncio.AbstractEventLoop.sock_recvfrom` and - :meth:`~asyncio.AbstractEventLoop.sock_recvfrom_into`. + :meth:`~asyncio.loop.sock_sendto`, + :meth:`~asyncio.loop.sock_recvfrom` and + :meth:`~asyncio.loop.sock_recvfrom_into`. These have implementations in :class:`~asyncio.SelectorEventLoop` and :class:`~asyncio.ProactorEventLoop`. (Contributed by Alex Grönholm in :issue:`46805`.) From be10008cf22205b7e29768d4f404ccc76ac57cb4 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Oct 2022 08:05:30 -0700 Subject: [PATCH 4/8] Add create_connection(...all_errors=...) --- Doc/whatsnew/3.11.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 728f58c57d8c4b..0ae1195f786c27 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -553,6 +553,9 @@ asyncio :exc:`~asyncio.BrokenBarrierError` exception. (Contributed by Yves Duprat and Andrew Svetlov in :gh:`87518`.) +* Add keyword argument ``all_errors`` to :func:`asyncio.loop.create_connection` + so that multiple connection errors can be raised as an :exc:`ExceptionGroup`. + * Added the :meth:`~asyncio.StreamWriter.start_tls` method for upgrading existing stream-based connections to TLS. (Contributed by Ian Good in :issue:`34975`.) From b1af2e9c30cb010ed686d96fbf43c0e4101c554e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Oct 2022 09:47:11 -0700 Subject: [PATCH 5/8] Whoops Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- Doc/whatsnew/3.11.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 0ae1195f786c27..130853c030057f 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -537,7 +537,7 @@ asyncio holding a group of tasks that will wait for all of them upon exit. For new code this is recommended over using :func:`~asyncio.create_task` and :func:`~asyncio.gather` directly. - (Contributed by Yury Seliganov and others in :gh:`90908`.) + (Contributed by Yury Selivanov and others in :gh:`90908`.) * Added :func:`~asyncio.timeout`, an asynchronous context manager for setting a timeout on asynchronous operations. For new code this is From d96bfdcddba18654746c3cb9243f3bf74f244b43 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Oct 2022 10:15:04 -0700 Subject: [PATCH 6/8] Selected CAM suggestions Co-authored-by: C.A.M. Gerlach --- Doc/whatsnew/3.11.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 130853c030057f..d0a1e6ee5589c2 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -553,10 +553,10 @@ asyncio :exc:`~asyncio.BrokenBarrierError` exception. (Contributed by Yves Duprat and Andrew Svetlov in :gh:`87518`.) -* Add keyword argument ``all_errors`` to :func:`asyncio.loop.create_connection` +* Add keyword argument *all_errors* to :meth:`asyncio.loop.create_connection` so that multiple connection errors can be raised as an :exc:`ExceptionGroup`. -* Added the :meth:`~asyncio.StreamWriter.start_tls` method for +* Added the :meth:`asyncio.StreamWriter.start_tls` method for upgrading existing stream-based connections to TLS. (Contributed by Ian Good in :issue:`34975`.) From b1514aefb65e0a70815d9c055222d51320f82887 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Oct 2022 10:15:45 -0700 Subject: [PATCH 7/8] Update label Co-authored-by: C.A.M. Gerlach --- Doc/whatsnew/3.11.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index d0a1e6ee5589c2..56d7c355d210e3 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -529,6 +529,8 @@ New Modules Improved Modules ================ +.. _whatsnew311-asyncio: + asyncio ------- From 7f44bb372869e865e745a31cbb91ba4050d47da9 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Oct 2022 10:58:17 -0700 Subject: [PATCH 8/8] Jelle's fix Co-authored-by: Jelle Zijlstra --- Doc/whatsnew/3.11.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 56d7c355d210e3..0d38abfc000597 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -555,7 +555,7 @@ asyncio :exc:`~asyncio.BrokenBarrierError` exception. (Contributed by Yves Duprat and Andrew Svetlov in :gh:`87518`.) -* Add keyword argument *all_errors* to :meth:`asyncio.loop.create_connection` +* Added keyword argument *all_errors* to :meth:`asyncio.loop.create_connection` so that multiple connection errors can be raised as an :exc:`ExceptionGroup`. * Added the :meth:`asyncio.StreamWriter.start_tls` method for