mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.11] gh-88863: Clear ref cycles to resolve leak when asyncio.open_connection raises (GH-95739) (#99721)
Break reference cycles to resolve memory leak, by
removing local exception and future instances from the frame.
(cherry picked from commit 995f6170c7
)
Co-authored-by: Dong Uk, Kang <nailbrainz@gmail.com>
This commit is contained in:
parent
609273eb52
commit
24fad64cef
4 changed files with 36 additions and 12 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()
|
||||
|
@ -841,6 +845,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