Skip to content

Commit 4bbb9f6

Browse files
miss-islingtonserhiy-storchakapitrou
authored
[3.12] gh-75128: Ignore EADDRNOTAVAIL error in asyncio.BaseEventLoop.create_server() (GH-114420) (GH-114441)
(cherry picked from commit a53e56e) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]>
1 parent 4890ac1 commit 4bbb9f6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Lib/asyncio/base_events.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import collections
1717
import collections.abc
1818
import concurrent.futures
19+
import errno
1920
import functools
2021
import heapq
2122
import itertools
@@ -1556,9 +1557,22 @@ async def create_server(
15561557
try:
15571558
sock.bind(sa)
15581559
except OSError as err:
1559-
raise OSError(err.errno, 'error while attempting '
1560-
'to bind on address %r: %s'
1561-
% (sa, err.strerror.lower())) from None
1560+
msg = ('error while attempting '
1561+
'to bind on address %r: %s'
1562+
% (sa, err.strerror.lower()))
1563+
if err.errno == errno.EADDRNOTAVAIL:
1564+
# Assume the family is not enabled (bpo-30945)
1565+
sockets.pop()
1566+
sock.close()
1567+
if self._debug:
1568+
logger.warning(msg)
1569+
continue
1570+
raise OSError(err.errno, msg) from None
1571+
1572+
if not sockets:
1573+
raise OSError('could not bind on any address out of %r'
1574+
% ([info[4] for info in infos],))
1575+
15621576
completed = True
15631577
finally:
15641578
if not completed:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ignore an :exc:`OSError` in :meth:`asyncio.BaseEventLoop.create_server` when
2+
IPv6 is available but the interface cannot actually support it.

0 commit comments

Comments
 (0)