Skip to content

Commit

Permalink
[3.12] pythonGH-106684: Close asyncio.StreamWriter when `asyncio.St…
Browse files Browse the repository at this point in the history
…reamWriter` is not closed by application (pythonGH-107650) (python#107656)

pythonGH-106684: raise `ResourceWarning` when `asyncio.StreamWriter` is not closed (pythonGH-107650)
(cherry picked from commit 41178e4)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 10, 2023
1 parent a71500c commit 7853c76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Lib/asyncio/streams.py
Expand Up @@ -392,6 +392,10 @@ async def start_tls(self, sslcontext, *,
self._transport = new_transport
protocol._replace_writer(self)

def __del__(self):
if not self._transport.is_closing():
self.close()


class StreamReader:

Expand Down
@@ -0,0 +1 @@
Close :class:`asyncio.StreamWriter` when it is not closed by application leading to memory leaks. Patch by Kumar Aditya.

0 comments on commit 7853c76

Please sign in to comment.