From cb2f8d66e36a8801520dcc1d62ba62a850d4570a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 18 Jan 2023 15:28:35 -1000 Subject: [PATCH 1/4] gh-101143: Remove references to TimerHandle from asyncio.base_events.BaseEventLoop._add_callback After 592ada9b4b08ad57037e365b9c462d71c96e4453 this function never adds to _scheduled --- Lib/asyncio/base_events.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index cbabb43ae0600a..070ea1044dd9d9 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1857,12 +1857,10 @@ def call_exception_handler(self, context): exc_info=True) def _add_callback(self, handle): - """Add a Handle to _scheduled (TimerHandle) or _ready.""" + """Add a Handle to _ready.""" assert isinstance(handle, events.Handle), 'A Handle is required here' - if handle._cancelled: - return - assert not isinstance(handle, events.TimerHandle) - self._ready.append(handle) + if not handle._cancelled: + self._ready.append(handle) def _add_callback_signalsafe(self, handle): """Like _add_callback() but called from a signal handler.""" From 521855153d76e284cc195896c009cdaccfcc3d4e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 20 Jan 2023 10:47:49 -1000 Subject: [PATCH 2/4] add NEWS --- .../next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst diff --git a/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst b/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst new file mode 100644 index 00000000000000..728b990b32f52d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst @@ -0,0 +1,2 @@ +Remove unused references to TimerHandle in +asyncio.base_events.BaseEventLoop._add_callback From 7ee5f56e9b8ce8329ff3387314848affb783b83f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 20 Jan 2023 11:31:09 -1000 Subject: [PATCH 3/4] Drop assertion --- Lib/asyncio/base_events.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 070ea1044dd9d9..32d7e1c481ecc5 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1858,7 +1858,6 @@ def call_exception_handler(self, context): def _add_callback(self, handle): """Add a Handle to _ready.""" - assert isinstance(handle, events.Handle), 'A Handle is required here' if not handle._cancelled: self._ready.append(handle) From cd82074ce8b5512debc2e93e2c5be5ab8dca63d8 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sat, 21 Jan 2023 14:15:05 +0530 Subject: [PATCH 4/4] Update Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst --- .../Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst b/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst index 728b990b32f52d..d14b9e25a691fc 100644 --- a/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst +++ b/Misc/NEWS.d/next/Library/2023-01-20-10-46-59.gh-issue-101143.hJo8hu.rst @@ -1,2 +1,2 @@ -Remove unused references to TimerHandle in -asyncio.base_events.BaseEventLoop._add_callback +Remove unused references to :class:`~asyncio.TimerHandle` in +``asyncio.base_events.BaseEventLoop._add_callback``.