mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-75128: Ignore EADDRNOTAVAIL error in asyncio.BaseEventLoop.create_server() (GH-114420) (GH-114441)
(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
4890ac136b
commit
4bbb9f6f29
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
|
||||||
import collections.abc
|
import collections.abc
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
import errno
|
||||||
import functools
|
import functools
|
||||||
import heapq
|
import heapq
|
||||||
import itertools
|
import itertools
|
||||||
|
@ -1556,9 +1557,22 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
try:
|
try:
|
||||||
sock.bind(sa)
|
sock.bind(sa)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
raise OSError(err.errno, 'error while attempting '
|
msg = ('error while attempting '
|
||||||
'to bind on address %r: %s'
|
'to bind on address %r: %s'
|
||||||
% (sa, err.strerror.lower())) from None
|
% (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
|
completed = True
|
||||||
finally:
|
finally:
|
||||||
if not completed:
|
if not completed:
|
||||||
|
|
|
@ -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.
|
Loading…
Add table
Add a link
Reference in a new issue