mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] gh-75128: Ignore EADDRNOTAVAIL error in asyncio.BaseEventLoop.create_server() (GH-114420) (GH-114442)
(cherry picked from commit a53e56e7d8
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
This commit is contained in:
parent
5b12f7d2bd
commit
acea9d8e87
2 changed files with 19 additions and 3 deletions
|
@ -16,6 +16,7 @@ to modify the meaning of the API call itself.
|
|||
import collections
|
||||
import collections.abc
|
||||
import concurrent.futures
|
||||
import errno
|
||||
import functools
|
||||
import heapq
|
||||
import itertools
|
||||
|
@ -1522,9 +1523,22 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue