Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() #23554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Prev Previous commit
Next Next commit
Add documentation.
  • Loading branch information
serhiy-storchaka committed Dec 6, 2020
commit b717f71a4a9c2d6cd99656ca708f24b7c1b094c0
5 changes: 5 additions & 0 deletions 5 Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions 12 Doc/library/asyncio-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions 17 Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,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
===========================
Expand Down Expand Up @@ -430,6 +435,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
========
Expand Down Expand Up @@ -589,6 +598,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
==================
Expand Down Expand Up @@ -771,6 +784,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.
Expand Down
13 changes: 13 additions & 0 deletions 13 Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,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`.)


Removed
=======
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Deprecated use of :func:`asyncio.get_event_loop` without running event loop.
Emit deprecation warning for :mod:`asyncio` functions which implicitly
create a :class:`~asyncio.Future` or :class:`~asyncio.Task` objects 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`.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.