From 84db86de6a787b2653f3b8b4379ad337057ec62f Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 29 Oct 2026 11:13:25 +0300 Subject: [PATCH] gh-151950: Document `asyncio.BaseEventLoop` and fix `asyncio-extending.rst` (GH-151976) * gh-151950: Document `async.BaseEventLoop` and fix `asyncio-extending.rst` * Apply suggestions from code review Co-authored-by: Stan Ulbrych * Update Doc/library/asyncio-extending.rst Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --------- (cherry picked from commit 16f209ba7d812e27554ad5c809af0c899341eaa1) Co-authored-by: sobolevn Co-authored-by: Stan Ulbrych Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Andrew Svetlov --- Doc/library/asyncio-eventloop.rst | 11 +++++++++++ Doc/library/asyncio-extending.rst | 11 +++++++---- Doc/tools/.nitignore | 1 - 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 99c795b04fa6d6..83907ca3773dff 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1967,6 +1967,17 @@ By default asyncio is configured to use :class:`EventLoop`. methods that an alternative implementation of ``AbstractEventLoop`` should have defined. +.. class:: BaseEventLoop + + A base class that partially implements :class:`AbstractEventLoop` + to simplify writing custom event loops. + + It provides default implementations of many :class:`AbstractEventLoop` + methods, so subclasses have fewer methods to implement themselves. + In return, a subclass is expected to implement a number of internal, + protected methods. + See :ref:`writing_custom_event_loop` for more information. + Examples ======== diff --git a/Doc/library/asyncio-extending.rst b/Doc/library/asyncio-extending.rst index e7b293f484f8de..0be79359b75e32 100644 --- a/Doc/library/asyncio-extending.rst +++ b/Doc/library/asyncio-extending.rst @@ -12,14 +12,17 @@ classes. Asyncio has helpers that could be used to simplify this task. Third-parties should reuse existing asyncio code with caution, a new Python version is free to break backward compatibility - in *internal* part of API. + in the *internal* part of the API. -Writing a Custom Event Loop +.. _writing_custom_event_loop: + +Writing a custom event loop =========================== -:class:`asyncio.AbstractEventLoop` declares very many methods. Implementing all them -from scratch is a tedious job. +:class:`asyncio.AbstractEventLoop` declares very many methods. +See :ref:`asyncio-event-loop-methods` for the full list. +Implementing them all from scratch is a tedious job. A loop can get many common methods implementation for free by inheriting from :class:`asyncio.BaseEventLoop`. diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 9bd913b47cabb9..deaa5c249ce01b 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -3,7 +3,6 @@ # Keep lines sorted lexicographically to help avoid merge conflicts. Doc/library/ast.rst -Doc/library/asyncio-extending.rst Doc/library/logging.config.rst Doc/library/logging.handlers.rst Doc/library/multiprocessing.rst