bpo-34638: Store a weak reference to stream reader to break strong references loop (GH-9201)
Store a weak reference to stream readerfor breaking strong references
It breaks the strong reference loop between reader and protocol and allows to detect and close the socket if the stream is deleted (garbage collected)
diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py
index 90fc00d..c86de3d 100644
--- a/Lib/asyncio/subprocess.py
+++ b/Lib/asyncio/subprocess.py
@@ -36,6 +36,11 @@
info.append(f'stderr={self.stderr!r}')
return '<{}>'.format(' '.join(info))
+ def _untrack_reader(self):
+ # StreamWriter.close() expects the protocol
+ # to have this method defined.
+ pass
+
def connection_made(self, transport):
self._transport = transport