aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py8
-rw-r--r--Lib/asyncio/unix_events.py3
2 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 3d4a87afdb2..1c7073c3703 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -412,6 +412,10 @@ class BaseEventLoop(events.AbstractEventLoop):
if sock is not None:
sock.close()
exceptions.append(exc)
+ except:
+ if sock is not None:
+ sock.close()
+ raise
else:
break
else:
@@ -512,6 +516,10 @@ class BaseEventLoop(events.AbstractEventLoop):
if sock is not None:
sock.close()
exceptions.append(exc)
+ except:
+ if sock is not None:
+ sock.close()
+ raise
else:
break
else:
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 1fbdd313a8f..230fbc38b41 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -223,6 +223,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
raise OSError(errno.EADDRINUSE, msg) from None
else:
raise
+ except:
+ sock.close()
+ raise
else:
if sock is None:
raise ValueError(