[Python-checkins] gh-100348: Fix ref cycle in `asyncio._SelectorSocketTransport` with `_read_ready_cb` (#100349)

kumaraditya303 webhook-mailer at python.org
Tue Dec 20 05:41:23 EST 2022


https://github.com/python/cpython/commit/a6331b605e8044a205a113e1db87d2b0a53d0222
commit: a6331b605e8044a205a113e1db87d2b0a53d0222
branch: main
author: Richard Kojedzinszky <rkojedzinszky at users.noreply.github.com>
committer: kumaraditya303 <59607654+kumaraditya303 at users.noreply.github.com>
date: 2022-12-20T16:10:56+05:30
summary:

gh-100348: Fix ref cycle in `asyncio._SelectorSocketTransport` with `_read_ready_cb` (#100349)

files:
A Misc/NEWS.d/next/Library/2022-12-19-19-30-06.gh-issue-100348.o7IAHh.rst
M Lib/asyncio/selector_events.py

diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 3d30006198f6..74f289f0e6f8 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -1133,6 +1133,10 @@ def _make_empty_waiter(self):
     def _reset_empty_waiter(self):
         self._empty_waiter = None
 
+    def close(self):
+        self._read_ready_cb = None
+        super().close()
+
 
 class _SelectorDatagramTransport(_SelectorTransport, transports.DatagramTransport):
 
diff --git a/Misc/NEWS.d/next/Library/2022-12-19-19-30-06.gh-issue-100348.o7IAHh.rst b/Misc/NEWS.d/next/Library/2022-12-19-19-30-06.gh-issue-100348.o7IAHh.rst
new file mode 100644
index 000000000000..b5d4f7ca998c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-12-19-19-30-06.gh-issue-100348.o7IAHh.rst
@@ -0,0 +1,2 @@
+Fix ref cycle in :class:`!asyncio._SelectorSocketTransport` by removing ``_read_ready_cb`` in ``close``.
+



More information about the Python-checkins mailing list