File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 16
16
import collections
17
17
import collections .abc
18
18
import concurrent .futures
19
+ import errno
19
20
import heapq
20
21
import itertools
21
22
import logging
@@ -1349,9 +1350,22 @@ async def create_server(
1349
1350
try :
1350
1351
sock .bind (sa )
1351
1352
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
+
1355
1369
completed = True
1356
1370
finally :
1357
1371
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