Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import collections
import collections.abc
import concurrent.futures
import errno
import heapq
import itertools
import logging
Expand Down Expand Up @@ -1349,9 +1350,22 @@ async def create_server(
try:
sock.bind(sa)
except OSError as err:
raise OSError(err.errno, 'error while attempting '
'to bind on address %r: %s'
% (sa, err.strerror.lower())) from None
msg = f'error while attempting to bind on address' \
f'{sa!r}: {err.strerror.lower()}'
if err.errno == errno.EADDRNOTAVAIL:
# Assume the family is not enabled (bpo-30945)
sockets.pop()
sock.close()
logger.warning(msg)
continue
raise OSError(err.errno, msg) from err

if not sockets:
failed_addrs = [info[4] for info in infos]
raise OSError(
f'could not bind on any address out of '
f'{failed_addrs!r}')

completed = True
finally:
if not completed:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix create_server() to handle the case when interface is not IPv6 enabled