Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def send(self, request, **kwargs): # type: ignore
allow_redirects=False,
**kwargs)

except urllib3.exceptions.NewConnectionError as err:
except (urllib3.exceptions.NewConnectionError, urllib3.exceptions.ConnectTimeoutError) as err:
error = ServiceRequestError(err, error=err)
except requests.exceptions.ReadTimeout as err:
error = ServiceResponseError(err, error=err)
Expand Down
16 changes: 15 additions & 1 deletion sdk/core/azure-core/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
RequestsTransport
)

from azure.core.configuration import Configuration
from azure.core.exceptions import AzureError


def test_sans_io_exception():
Expand Down Expand Up @@ -107,6 +107,20 @@ def test_basic_requests(self):
assert pipeline._transport.session is None
assert response.http_response.status_code == 200

def test_requests_socket_timeout(self):
conf = Configuration()
request = HttpRequest("GET", "https://bing.com")
policies = [
UserAgentPolicy("myusergant"),
RedirectPolicy()
]
# Sometimes this will raise a read timeout, sometimes a socket timeout depending on timing.
# Either way, the error should always be wrapped as an AzureError to ensure it's caught
# by the retry policy.
with pytest.raises(AzureError):
with Pipeline(RequestsTransport(), policies=policies) as pipeline:
response = pipeline.run(request, connection_timeout=0.000001)

def test_basic_requests_separate_session(self):

session = requests.Session()
Expand Down