mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-88863: Clear ref cycles to resolve leak when asyncio.open_connection raises (#95739)
Break reference cycles to resolve memory leak, by removing local exception and future instances from the frame
This commit is contained in:
parent
9a91182d4a
commit
995f6170c7
4 changed files with 38 additions and 14 deletions
|
|
@ -439,7 +439,11 @@ class IocpProactor:
|
|||
self._poll(timeout)
|
||||
tmp = self._results
|
||||
self._results = []
|
||||
return tmp
|
||||
try:
|
||||
return tmp
|
||||
finally:
|
||||
# Needed to break cycles when an exception occurs.
|
||||
tmp = None
|
||||
|
||||
def _result(self, value):
|
||||
fut = self._loop.create_future()
|
||||
|
|
@ -793,6 +797,8 @@ class IocpProactor:
|
|||
else:
|
||||
f.set_result(value)
|
||||
self._results.append(f)
|
||||
finally:
|
||||
f = None
|
||||
|
||||
# Remove unregistered futures
|
||||
for ov in self._unregistered:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue