diff options
author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2021-01-20 16:16:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 16:16:12 -0800 |
commit | dcea78ff53d02733ac5983255610b651aa1c0034 (patch) | |
tree | 1815227fb9569126c82a0bcdfcb3c93740304582 /Doc | |
parent | bpo-40176: Improve error messages for unclosed string literals (GH-19346) (diff) | |
download | cpython-dcea78ff53d02733ac5983255610b651aa1c0034.tar.gz cpython-dcea78ff53d02733ac5983255610b651aa1c0034.tar.bz2 cpython-dcea78ff53d02733ac5983255610b651aa1c0034.zip |
bpo-42392: Mention loop removal in whatsnew for 3.10 (GH-24256)
@vstinner [noticed on python-dev](https://mail.python.org/archives/list/python-dev@python.org/thread/O3T7SK3BGMFWMLCQXDODZJSBL42AUWTR/) that there is no what's new or porting entry for removal of asyncio ``loop`` parameter.
This patch adds a basic guide.
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/whatsnew/3.10.rst | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 7fe2b96a00e..0fca2e8b8c3 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -558,6 +558,23 @@ Removed the :mod:`collections` module. (Contributed by Victor Stinner in :issue:`37324`.) +* The ``loop`` parameter has been removed from most of :mod:`asyncio`\ 's + :doc:`high-level API <../library/asyncio-api-index>` following deprecation + in Python 3.8. The motivation behind this change is multifold: + + 1. This simplifies the high-level API. + 2. The functions in the high-level API have been implicitly getting the + current thread's running event loop since Python 3.7. There isn't a need to + pass the event loop to the API in most normal use cases. + 3. Event loop passing is error-prone especially when dealing with loops + running in different threads. + + Note that the low-level API will still accept ``loop``. + See `Changes in the Python API`_ for examples of how to replace existing code. + + (Contributed by Yurii Karabas, Andrew Svetlov, Yury Selivanov and Kyle Stanley + in :issue:`42392`.) + Porting to Python 3.10 ====================== @@ -596,6 +613,26 @@ Changes in the Python API a 16-bit unsigned integer. (Contributed by Erlend E. Aasland in :issue:`42393`.) +* The ``loop`` parameter has been removed from most of :mod:`asyncio`\ 's + :doc:`high-level API <../library/asyncio-api-index>` following deprecation + in Python 3.8. + + A coroutine that currently look like this:: + + async def foo(loop): + await asyncio.sleep(1, loop=loop) + + Should be replaced with this:: + + async def foo(): + await asyncio.sleep(1) + + If ``foo()`` was specifically designed *not* to run in the current thread's + running event loop (e.g. running in another thread's event loop), consider + using :func:`asyncio.run_coroutine_threadsafe` instead. + + (Contributed by Yurii Karabas, Andrew Svetlov, Yury Selivanov and Kyle Stanley + in :issue:`42392`.) CPython bytecode changes ======================== |