Skip to content

gh-75128: Ignore EADDRNOTAVAIL error in asyncio.BaseEventLoop.create_server() #114420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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 functools
import heapq
import itertools
Expand Down Expand Up @@ -1585,9 +1586,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 = ('error while attempting '
'to bind on address %r: %s'
% (sa, err.strerror.lower()))
if err.errno == errno.EADDRNOTAVAIL:
# Assume the family is not enabled (bpo-30945)
sockets.pop()
sock.close()
if self._debug:
logger.warning(msg)
continue
raise OSError(err.errno, msg) from None

if not sockets:
raise OSError('could not bind on any address out of %r'
% ([info[4] for info in infos],))

completed = True
finally:
if not completed:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ignore an :exc:`OSError` in :meth:`asyncio.BaseEventLoop.create_server` when
IPv6 is available but the interface cannot actually support it.