Skip to content

Commit

Permalink
Retry when server reports 429 Too Many Requests occurs
Browse files Browse the repository at this point in the history
An HTTP/1.1 429 Too Many Requests occurs when:

* there are too many requests
* server is overloaded

The server may respond back with a `Retry-after` field with the value in
seconds. For now, we'll just retry immediately. A potential enhancement
could be to honor `Retry-after` but, thinking of it, it doesn't fit the
bill for `apt-offline` because we want the download operation to
conclude immediately rather than wait for `Retry-after` seconds.

Thanks: Zoltan Kelemen (Github: misterzed88)
Closes: #213
  • Loading branch information
rickysarraf committed Aug 3, 2023
1 parent 561c9d1 commit 673c821
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apt_offline_core/AptOfflineCoreLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,10 @@ def errfunc(errno, errormsg, filename):
be well accessible.
This function does the job of behaving accordingly
as per the error codes.'''
retriable_error_codes = [-3, 13, 404, 403, 401, 10060, 104, 101010]
retriable_error_codes = [-3, 13, 404, 403, 401, 429, 10060, 104, 101010]
# 104, 'Connection reset by peer'
# 504 is for gateway timeout
# 429 Too Many Requests
# 404 is for URL error. Page not found.
# 401 is for Restricted pages
# 10060 is for Operation Time out. There can be multiple reasons for this timeout
Expand Down

0 comments on commit 673c821

Please sign in to comment.