mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
add retry error handling to _chunks()
Signed-off-by: NicholasTanz <nicholastanzillo@gmail.com>
This commit is contained in:
parent
2aed81f019
commit
a48fca51f9
2 changed files with 8 additions and 3 deletions
|
|
@ -109,7 +109,11 @@ def test_http_error(self) -> None:
|
|||
def test_response_read_timeout(self, mock_session_get: Mock) -> None:
|
||||
mock_response = Mock()
|
||||
mock_response.status = 200
|
||||
attr = {"stream.side_effect": urllib3.exceptions.TimeoutError}
|
||||
attr = {"stream.side_effect": urllib3.exceptions.MaxRetryError(
|
||||
urllib3.connectionpool.ConnectionPool("localhost"),
|
||||
"",
|
||||
urllib3.exceptions.TimeoutError(),
|
||||
)}
|
||||
mock_response.configure_mock(**attr)
|
||||
mock_session_get.return_value = mock_response
|
||||
|
||||
|
|
|
|||
|
|
@ -103,8 +103,9 @@ def _chunks(
|
|||
|
||||
try:
|
||||
yield from response.stream(self.chunk_size)
|
||||
except urllib3.exceptions.TimeoutError as e:
|
||||
raise exceptions.SlowRetrievalError from e
|
||||
except urllib3.exceptions.MaxRetryError as e:
|
||||
if isinstance(e.reason, urllib3.exceptions.TimeoutError):
|
||||
raise exceptions.SlowRetrievalError from e
|
||||
|
||||
finally:
|
||||
response.release_conn()
|
||||
|
|
|
|||
Loading…
Reference in a new issue