Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Doc/deprecations/pending-removal-in-3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,6 @@ Pending removal in Python 3.16
use :func:`inspect.iscoroutinefunction` instead.
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)

* :mod:`asyncio` policy system is deprecated and will be removed in Python 3.16.
In particular, the following classes and functions are deprecated:

* :class:`asyncio.AbstractEventLoopPolicy`
* :class:`asyncio.DefaultEventLoopPolicy`
* :class:`asyncio.WindowsSelectorEventLoopPolicy`
* :class:`asyncio.WindowsProactorEventLoopPolicy`
* :func:`asyncio.get_event_loop_policy`
* :func:`asyncio.set_event_loop_policy`

Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
*loop_factory* to use the desired event loop implementation.

For example, to use :class:`asyncio.SelectorEventLoop` on Windows::

import asyncio

async def main():
...

asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)

(Contributed by Kumar Aditya in :gh:`127949`.)

* :mod:`builtins`:

* Bitwise inversion on boolean types, ``~True`` or ``~False``
Expand Down
17 changes: 3 additions & 14 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ an event loop:
running event loop.

If there is no running event loop set, the function will return
the result of the ``get_event_loop_policy().get_event_loop()`` call.
the loop set by :func:`set_event_loop`, or raise a :exc:`RuntimeError`
if no loop has been set.

Because this function has rather complex behavior (especially
when custom event loop policies are in use), using the
Because this function has rather complex behavior, using the
:func:`get_running_loop` function is preferred to :func:`get_event_loop`
in coroutines and callbacks.

Expand All @@ -62,13 +62,6 @@ an event loop:
.. versionchanged:: 3.14
Raises a :exc:`RuntimeError` if there is no current event loop.

.. note::

The :mod:`!asyncio` policy system is deprecated and will be removed
in Python 3.16; from there on, this function will return the current
running event loop if present else it will return the
loop set by :func:`set_event_loop`.

.. function:: set_event_loop(loop)

Set *loop* as the current event loop for the current OS thread.
Expand All @@ -77,10 +70,6 @@ an event loop:

Create and return a new event loop object.

Note that the behaviour of :func:`get_event_loop`, :func:`set_event_loop`,
and :func:`new_event_loop` functions can be altered by
:ref:`setting a custom event loop policy <asyncio-policies>`.


.. rubric:: Contents

Expand Down
24 changes: 0 additions & 24 deletions Doc/library/asyncio-llapi-index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -497,27 +497,3 @@ Protocol classes can implement the following **callback methods**:
- Called when the child process has exited. It can be called before
:meth:`~SubprocessProtocol.pipe_data_received` and
:meth:`~SubprocessProtocol.pipe_connection_lost` methods.


Event Loop Policies
===================

Policies is a low-level mechanism to alter the behavior of
functions like :func:`asyncio.get_event_loop`. See also
the main :ref:`policies section <asyncio-policies>` for more
details.


.. rubric:: Accessing Policies
.. list-table::
:widths: 50 50
:class: full-width-table

* - :meth:`asyncio.get_event_loop_policy`
- Return the current process-wide policy.

* - :meth:`asyncio.set_event_loop_policy`
- Set a new process-wide policy.

* - :class:`AbstractEventLoopPolicy`
- Base class for policy objects.
173 changes: 0 additions & 173 deletions Doc/library/asyncio-policy.rst

This file was deleted.

10 changes: 1 addition & 9 deletions Doc/library/asyncio-runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ Running an asyncio Program
otherwise :func:`asyncio.new_event_loop` is used. The loop is closed at the end.
This function should be used as a main entry point for asyncio programs,
and should ideally only be called once. It is recommended to use
*loop_factory* to configure the event loop instead of policies.
Passing :class:`asyncio.EventLoop` allows running asyncio without the
policy system.
*loop_factory* to configure the event loop.

The executor is given a timeout duration of 5 minutes to shutdown.
If the executor hasn't finished within that duration, a warning is
Expand Down Expand Up @@ -76,12 +74,6 @@ Running an asyncio Program

*coro* can be any awaitable object.

.. note::

The :mod:`!asyncio` policy system is deprecated and will be removed
in Python 3.16; from there on, an explicit *loop_factory* is needed
to configure the event loop.


Runner context manager
======================
Expand Down
1 change: 0 additions & 1 deletion Doc/library/asyncio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ for full functionality and the latest features.
asyncio-eventloop.rst
asyncio-future.rst
asyncio-protocol.rst
asyncio-policy.rst
asyncio-platforms.rst
asyncio-extending.rst

Expand Down
12 changes: 6 additions & 6 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2628,12 +2628,12 @@ New deprecations
and will be removed in Python 3.16.
In particular, the following classes and functions are deprecated:

* :class:`asyncio.AbstractEventLoopPolicy`
* :class:`asyncio.DefaultEventLoopPolicy`
* :class:`asyncio.WindowsSelectorEventLoopPolicy`
* :class:`asyncio.WindowsProactorEventLoopPolicy`
* :func:`asyncio.get_event_loop_policy`
* :func:`asyncio.set_event_loop_policy`
* :class:`!asyncio.AbstractEventLoopPolicy`
* :class:`!asyncio.DefaultEventLoopPolicy`
* :class:`!asyncio.WindowsSelectorEventLoopPolicy`
* :class:`!asyncio.WindowsProactorEventLoopPolicy`
* :func:`!asyncio.get_event_loop_policy`
* :func:`!asyncio.set_event_loop_policy`

Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
the *loop_factory* argument to use the desired event loop implementation.
Expand Down
11 changes: 11 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ asyncio
which has been deprecated since Python 3.14.
Use :func:`inspect.iscoroutinefunction` instead.

* The event loop policy system, including the
:class:`!asyncio.AbstractEventLoopPolicy`,
:class:`!asyncio.DefaultEventLoopPolicy`,
:class:`!asyncio.WindowsSelectorEventLoopPolicy` and
:class:`!asyncio.WindowsProactorEventLoopPolicy` classes and the
:func:`!asyncio.get_event_loop_policy` and
:func:`!asyncio.set_event_loop_policy` functions,
which have been deprecated since Python 3.14.
Use :func:`asyncio.run` or :class:`asyncio.Runner` with a custom
*loop_factory* instead.

functools
---------

Expand Down
25 changes: 0 additions & 25 deletions Lib/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,3 @@
else:
from .unix_events import * # pragma: no cover
__all__ += unix_events.__all__

def __getattr__(name: str):
import warnings

match name:
case "AbstractEventLoopPolicy":
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
return events._AbstractEventLoopPolicy
case "DefaultEventLoopPolicy":
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
if sys.platform == 'win32':
return windows_events._DefaultEventLoopPolicy
return unix_events._DefaultEventLoopPolicy
case "WindowsSelectorEventLoopPolicy":
if sys.platform == 'win32':
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
return windows_events._WindowsSelectorEventLoopPolicy
# Else fall through to the AttributeError below.
case "WindowsProactorEventLoopPolicy":
if sys.platform == 'win32':
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
return windows_events._WindowsProactorEventLoopPolicy
# Else fall through to the AttributeError below.

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Loading
Loading