You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asyncio leaks transport/protocol/SSLObject on failed TLS handshake: SSLError traceback forms a reference cycle #159049
When a proactive TLS handshake performed by loop.create_connection() fails (e.g. with ssl.SSLCertVerificationError: CERTIFICATE_VERIFY_FAILED).
The objects are only freed by the cyclic garbage collector, never by reference counting.
The same scenario under uvloop shows no such cycle.
If you clear the traceback from the exception object, the memory stops flowing.
3. Hey, it's not really a leak, because sooner gc will collect those objects. But, if you don't mind i can work on this
I completely agree that this isn’t exactly a leak. But in a high‑load application, you want to avoid running the gc. It would be great if you could resolve this case.
6. I completely agree that this isn’t exactly a leak. But in a high‑load application, you want to avoid running the gc. It would be great if you could resolve this case.
Activity
rus1g commentedon Oct 9, 2026
Check the small monkeypatch, after which memory leaks stopped. I hope this will help in finding the problem.
del waiterto _create_connection_transport — this solved the problem almost completely, but not fully.self._read_ready_cb = Noneto _call_connection_lost — this solved the problem completely.deadlovelll commentedon Oct 9, 2026
Hey, it's not really a leak, because sooner gc will collect those objects. But, if you don't mind i can work on this
sergey-miryanov commentedon Oct 9, 2026
@deadlovelll You may be interested in #142516
rus1g commentedon Oct 10, 2026
I completely agree that this isn’t exactly a leak. But in a high‑load application, you want to avoid running the gc. It would be great if you could resolve this case.
deadlovelll commentedon Oct 10, 2026
Thanks, i'll push a pr soon
pythongh-159049: Fix reference cycles after a failed TLS handshake in…
pythongh-159049: Fix reference cycles after a failed TLS handshake in…
deadlovelll commentedon Oct 10, 2026
Wrote benchmark to measure the output:
GIL build:
FT build: