summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index bfa4590..3d30006 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -633,7 +633,11 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
fut = self.create_future()
self._sock_connect(fut, sock, address)
- return await fut
+ try:
+ return await fut
+ finally:
+ # Needed to break cycles when an exception occurs.
+ fut = None
def _sock_connect(self, fut, sock, address):
fd = sock.fileno()
@@ -655,6 +659,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
fut.set_exception(exc)
else:
fut.set_result(None)
+ finally:
+ fut = None
def _sock_write_done(self, fd, fut, handle=None):
if handle is None or not handle.cancelled():
@@ -678,6 +684,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
fut.set_exception(exc)
else:
fut.set_result(None)
+ finally:
+ fut = None
async def sock_accept(self, sock):
"""Accept a connection.