[3.12] GH-106684: Close `asyncio.StreamWriter` when `asyncio.StreamWriter` is not closed by application (GH-107650) (GH-107656)
GH-106684: raise `ResourceWarning` when `asyncio.StreamWriter` is not closed (GH-107650)
(cherry picked from commit
41178e41995992bbe417f94bce158de93f9e3188)
(cherry picked from commit
7853c769067699c79c0d4fe4967e9d8f8b8b0a5e)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
self._transport = new_transport
protocol._replace_writer(self)
+ def __del__(self):
+ if not self._transport.is_closing():
+ self.close()
+
class StreamReader:
--- /dev/null
+Close :class:`asyncio.StreamWriter` when it is not closed by application leading to memory leaks. Patch by Kumar Aditya.