Skip to content

Conversation

@ishaanxgupta
Copy link

@ishaanxgupta ishaanxgupta commented Jan 7, 2026

Collaborated with @hemang1404

Description of the changes being introduced by the pull request:
Configure urllib3 Retry with 3 retries for read/connect timeouts

  • Add exception handling for ReadTimeoutError and ProtocolError during streaming
  • Override download_bytes to retry entire download on SlowRetrievalError
  • Fixes issue where mid-stream timeouts were not automatically retried

Fixes #2842

@jku please have a look and if there are any changes please let us know

Co-authored-by: Ishaan Gupta  <ishaankone@gmail.com>

Signed-off-by: Hemang Sharrma <hemangsharrma@gmail.com>
@ishaanxgupta ishaanxgupta requested a review from a team as a code owner January 7, 2026 08:14
@jku
Copy link
Member

jku commented Jan 7, 2026

please have a look and if there are any changes please let us know

Thanks, I should have time for this next week.

In the mean time, could you talk about how you tested that this really works and whether there is a way to test in our test suite? the whole download code is now pretty complicated (and an absolutely core part of the software) so I'd feel more sure about this if it was thoroughly tested...

With regards to the failing lint: You can run tox -e lint locally to get the same results (and tox -e py to run existing tests)


self._proxy_env = ProxyEnvironment(headers={"User-Agent": ua})
# Configure retry strategy: retry on read timeouts and connection errors
# This enables retries for streaming failures, not just initial connection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am I correct that retry_strategy variable does not actually affect the streaming retries at all? it seems to be a completely separate implementation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is useful if the connection fails before streaming, although this shouldn't be a part of this PR, I could remove it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it seems to be codifying the default urllib3 behaviour here. I'm asking about the comment that seems to claim that setting retry_strategy enables retries for streaming failures

Co-authored-by: Vedant Mahajan <vedant.04.mahajan@gmail.com>
Signed-off-by: Hemang Sharrma <hemangsharrma@gmail.com>
@jku
Copy link
Member

jku commented Jan 7, 2026

Coverage failure: total of 96 is less than fail-under=97

If you want to see the tests run on CI you can lower the --fail-under limit in tox.ini for now -- but actually getting the code tested would also fix this...

…comment

Signed-off-by: Hemang Sharrma <hemangsharrma@gmail.com>
@hemang1404
Copy link

hemang1404 commented Jan 7, 2026

@jku Thank you for the feedback. The comment on retry_strategy variable was misleading as it only handles retries before streaming begins. I fixed the comment and added 5 comprehensive tests to test_fetcher_ng.py, these test the case where urllib3's built-in retries don't help because the failure happens after the HTTP request completes. Coverage should now exceed 97%.

@coveralls
Copy link

Coverage Status

coverage: 97.047% (-0.2%) from 97.284%
when pulling 87e9cd1 on hemang1404:develop
into b21206d on theupdateframework:develop.

@ishaanxgupta ishaanxgupta requested a review from jku January 7, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate/test fetcher retries

4 participants