bpo-36629: Add support.get_socket_conn_refused_errs() (GH-12834) (GH-… · python/cpython@28ed39e (original) (raw)
`@@ -1409,6 +1409,22 @@ def exit(self, type_=None, value=None, traceback=None):
`
1409
1409
`ioerror_peer_reset = TransientResource(OSError, errno=errno.ECONNRESET)
`
1410
1410
``
1411
1411
``
``
1412
`+
def get_socket_conn_refused_errs():
`
``
1413
`+
"""
`
``
1414
`+
Get the different socket error numbers ('errno') which can be received
`
``
1415
`+
when a connection is refused.
`
``
1416
`+
"""
`
``
1417
`+
errors = [errno.ECONNREFUSED]
`
``
1418
`+
if hasattr(errno, 'ENETUNREACH'):
`
``
1419
`+
On Solaris, ENETUNREACH is returned sometimes instead of ECONNREFUSED
`
``
1420
`+
errors.append(errno.ENETUNREACH)
`
``
1421
`+
if hasattr(errno, 'EADDRNOTAVAIL'):
`
``
1422
`+
bpo-31910: socket.create_connection() fails randomly
`
``
1423
`+
with EADDRNOTAVAIL on Travis CI
`
``
1424
`+
errors.append(errno.EADDRNOTAVAIL)
`
``
1425
`+
return errors
`
``
1426
+
``
1427
+
1412
1428
`@contextlib.contextmanager
`
1413
1429
`def transient_internet(resource_name, *, timeout=30.0, errnos=()):
`
1414
1430
`"""Return a context manager that raises ResourceDenied when various issues
`