diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-04-25 10:40:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-25 10:40:44 (GMT) |
commit | 172c0f2752d8708b6dda7b42e6c5a3519420a4e8 (patch) | |
tree | 35a076c6baad7ca053a62b9f505af3762a867b79 /Doc | |
parent | face87c94e67ad9c72b9a3724f112fd76c1002b9 (diff) | |
download | cpython-172c0f2752d8708b6dda7b42e6c5a3519420a4e8.zip cpython-172c0f2752d8708b6dda7b42e6c5a3519420a4e8.tar.gz cpython-172c0f2752d8708b6dda7b42e6c5a3519420a4e8.tar.bz2 |
bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() (GH-23554)
asyncio.get_event_loop() emits now a deprecation warning when it creates a new event loop.
In future releases it will became an alias of asyncio.get_running_loop().
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/asyncio-eventloop.rst | 5 | ||||
-rw-r--r-- | Doc/library/asyncio-future.rst | 12 | ||||
-rw-r--r-- | Doc/library/asyncio-task.rst | 17 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 13 |
4 files changed, 47 insertions, 0 deletions
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 7de5a0a..ca91efe 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -53,6 +53,11 @@ an event loop: Consider also using the :func:`asyncio.run` function instead of using lower level functions to manually create and close an event loop. + .. deprecated:: 3.10 + Deprecation warning is emitted if there is no running event loop. + If future Python releases this function will be an alias of + :func:`get_running_loop`. + .. function:: set_event_loop(loop) Set *loop* as a current event loop for the current OS thread. diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index 939d4c1..ef496a2 100644 --- a/Doc/library/asyncio-future.rst +++ b/Doc/library/asyncio-future.rst @@ -57,12 +57,20 @@ Future Functions .. versionchanged:: 3.5.1 The function accepts any :term:`awaitable` object. + .. deprecated:: 3.10 + Deprecation warning is emitted if *obj* is not a Future-like object + and *loop* is not specified and there is no running event loop. + .. function:: wrap_future(future, *, loop=None) Wrap a :class:`concurrent.futures.Future` object in a :class:`asyncio.Future` object. + .. deprecated:: 3.10 + Deprecation warning is emitted if *future* is not a Future-like object + and *loop* is not specified and there is no running event loop. + Future Object ============= @@ -90,6 +98,10 @@ Future Object .. versionchanged:: 3.7 Added support for the :mod:`contextvars` module. + .. deprecated:: 3.10 + Deprecation warning is emitted if *loop* is not specified + and there is no running event loop. + .. method:: result() Return the result of the Future. diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index 1ca1b4a..3f54ecb 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -397,6 +397,11 @@ Running Tasks Concurrently If the *gather* itself is cancelled, the cancellation is propagated regardless of *return_exceptions*. + .. deprecated:: 3.10 + Deprecation warning is emitted if no positional arguments are provided + or not all positional arguments are Future-like objects + and there is no running event loop. + Shielding From Cancellation =========================== @@ -434,6 +439,10 @@ Shielding From Cancellation except CancelledError: res = None + .. deprecated:: 3.10 + Deprecation warning is emitted if *aw* is not Future-like object + and there is no running event loop. + Timeouts ======== @@ -593,6 +602,10 @@ Waiting Primitives earliest_result = await coro # ... + .. deprecated:: 3.10 + Deprecation warning is emitted if not all awaitable objects in the *aws* + iterable are Future-like objects and there is no running event loop. + Running in Threads ================== @@ -775,6 +788,10 @@ Task Object .. deprecated-removed:: 3.8 3.10 The *loop* parameter. + .. deprecated:: 3.10 + Deprecation warning is emitted if *loop* is not specified + and there is no running event loop. + .. method:: cancel(msg=None) Request the Task to be cancelled. diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index dac44cf..ab0b46f 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1349,6 +1349,19 @@ Deprecated scheduled for removal in Python 3.12. (Contributed by Erlend E. Aasland in :issue:`42264`.) +* :func:`asyncio.get_event_loop` emits now a deprecation warning if there is + no running event loop. In future it will be an alias of + :func:`~asyncio.get_running_loop`. + :mod:`asyncio` functions which implicitly create a :class:`~asyncio.Future` + or :class:`~asyncio.Task` objects emit now + a deprecation warning if there is no running event loop and no explicit + *loop* argument is passed: :func:`~asyncio.ensure_future`, + :func:`~asyncio.wrap_future`, :func:`~asyncio.gather`, + :func:`~asyncio.shield`, :func:`~asyncio.as_completed` and constructors of + :class:`~asyncio.Future`, :class:`~asyncio.Task`, + :class:`~asyncio.StreamReader`, :class:`~asyncio.StreamReaderProtocol`. + (Contributed by Serhiy Storchaka in :issue:`39529`.) + * The undocumented built-in function ``sqlite3.enable_shared_cache`` is now deprecated, scheduled for removal in Python 3.12. Its use is strongly discouraged by the SQLite3 documentation. See `the SQLite3 docs |