File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616import collections
1717import collections .abc
1818import concurrent .futures
19+ import errno
1920import heapq
2021import itertools
2122import logging
@@ -1349,9 +1350,22 @@ async def create_server(
13491350 try :
13501351 sock .bind (sa )
13511352 except OSError as err :
1352- raise OSError (err .errno , 'error while attempting '
1353- 'to bind on address %r: %s'
1354- % (sa , err .strerror .lower ())) from None
1353+ msg = f'error while attempting to bind on address' \
1354+ f'{ sa !r} : { err .strerror .lower ()} '
1355+ if err .errno == errno .EADDRNOTAVAIL :
1356+ # Assume the family is not enabled (bpo-30945)
1357+ sockets .pop ()
1358+ sock .close ()
1359+ logger .warning (msg )
1360+ continue
1361+ raise OSError (err .errno , msg ) from err
1362+
1363+ if not sockets :
1364+ failed_addrs = [info [4 ] for info in infos ]
1365+ raise OSError (
1366+ f'could not bind on any address out of '
1367+ f'{ failed_addrs !r} ' )
1368+
13551369 completed = True
13561370 finally :
13571371 if not completed :
Original file line number Diff line number Diff line change 1+ Fix create_server() to handle the case when interface is not IPv6 enabled
You can’t perform that action at this time.
0 commit comments