gh-74166: Add option to get all errors from socket.create_connection (GH-91586)

This commit is contained in:
Irit Katriel 2022-04-18 23:15:41 +01:00 committed by GitHub
parent 0860b26a4f
commit 39a54ba638
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 10 deletions

View file

@ -660,7 +660,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
Windows support added.
.. function:: create_connection(address[, timeout[, source_address]])
.. function:: create_connection(address[, timeout[, source_address[, all_errors]]])
Connect to a TCP service listening on the internet *address* (a 2-tuple
``(host, port)``), and return the socket object. This is a higher-level
@ -679,9 +679,18 @@ The following functions all create :ref:`socket objects <socket-objects>`.
socket to bind to as its source address before connecting. If host or port
are '' or 0 respectively the OS default behavior will be used.
When a connection cannot be created, an exception is raised. By default,
it is the exception from the last address in the list. If *all_errors*
is ``True``, it is an :exc:`ExceptionGroup` containing the errors of all
attempts.
.. versionchanged:: 3.2
*source_address* was added.
.. versionchanged:: 3.11
*all_errors* was added.
.. function:: create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, dualstack_ipv6=False)
Convenience function which creates a TCP socket bound to *address* (a 2-tuple