bpo-34745: Fix asyncio sslproto memory issues (GH-12386)
* Fix handshake timeout leak in asyncio/sslproto
Refs MagicStack/uvloopGH-222
* Break circular ref _SSLPipe <-> SSLProtocol
* bpo-34745: Fix asyncio ssl memory leak
* Break circular ref SSLProtocol <-> UserProtocol
* Add NEWS entry
(cherry picked from commit f683f464259715d620777d7ed568e701337a703a)
Co-authored-by: Fantix King <fantix.king@gmail.com>
diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py
index 12fdb0d..15eb9c7 100644
--- a/Lib/asyncio/sslproto.py
+++ b/Lib/asyncio/sslproto.py
@@ -499,7 +499,11 @@
self._app_transport._closed = True
self._transport = None
self._app_transport = None
+ if getattr(self, '_handshake_timeout_handle', None):
+ self._handshake_timeout_handle.cancel()
self._wakeup_waiter(exc)
+ self._app_protocol = None
+ self._sslpipe = None
def pause_writing(self):
"""Called when the low-level transport's buffer goes over