Repository navigation
Retry transient HTTP and host errors in save_large_file - #349
Conversation
816a90d to
1b7a481
Compare
|
Thank you, but it looks like this solution does not allowed zimwright to complete the download, so I'm not yet convinced this is the proper one to implement. |
744fd1e to
7ba29ee
Compare
|
The issue is that wget's @benoit74 once check please thanks! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #349 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 42 42
Lines 2729 2799 +70
Branches 406 417 +11
=========================================
+ Hits 2729 2799 +70 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@pawank925 please also do not merge from |
benoit74
left a comment
There was a problem hiding this comment.
@pawank925 please adopt latest changes in zimwright around this function (hence my initial recommendation to not start working on this too fast) and ensure code coverage is 100%
e241b51 to
c36850b
Compare
c36850b to
1353fa9
Compare
|
Rebased without merging and ported the latest zimwright |
changes
Make
save_large_filerobust to interrupted downloads, as reported in #348.save_large_fileshelled out to a singlewget -t {retries} ... -crun. The issue is not only that wget treats some transient errors as fatal: wget's-tis a budget for the whole download, not for consecutive failures. A connection that drops every few hundred MB therefore exhausts the budget and aborts with no further retry, even though every attempt resumes correctly — which is what was observed in openzim/zimwright#3.fix
Replace the wget shell-out with a streaming download built on
requests:Rangerequest, so an interrupted download continues instead of restarting;get_retry_adapterretries, with exponential backoff;404) raises the newDownloadErrorimmediately;Rangerequest (replies 200 to a range request), the file is started over.This matches the approach already used by zimwright, which can now rely on the library implementation instead of keeping its own copy.
Tests
New unit tests (no network,
requests.Session.getmocked) cover a clean download, resume after a dropped connection, retry on a transient HTTP status, restart when the server ignores the range, no retry on a non-retryable status, giving up afterretriesconsecutive no-progress attempts, and continuing pastretriesattempts as long as each makes progress. The existing slow tests exercise real downloads, and theogvjs/zimsuites that usesave_large_filestill pass.Closes #348.