8000 Add support for having a maximum retry after wait length. by alexjrk · Pull Request #3233 · urllib3/urllib3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

8000 Add support for having a maximum retry after wait length. #3233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

alexjrk
Copy link
@alexjrk alexjrk com 8000 mented Dec 14, 2023

Introducing a new feature that allows you to set a maximum duration for retry wait length using the max_retry_wait_length argument. If a response contains a Retry-After header with value greater than the maximum set and respect_retry_after_header is set to True, we will raise a MaxRetryWaitExceededError.

Fixes #1338

@@ -335,6 +338,8 @@ def get_retry_after(self, response: BaseHTTPResponse) -> float | None:
def sleep_for_retry(self, response: BaseHTTPResponse) -> bool:
retry_after = self.get_retry_after(response)
if retry_after:
if self.max_retry_wait_length and retry_after > self.max_retry_wait_length:
raise MaxRetryWaitExceededError(retry_after_header_value=retry_after)

Choose a reason for hiding this comment

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

The is_retry method probably should be updated too to respect the max_retry_wait_length.
e.g. the responses library relies on it.

Copy link
Author

Choose a reason for hiding this comment

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

Why? A response can still be a retry response even if its Retry-After header exceeds the limit, right? I don't see why we should raise an error just for checking this.

Copy link
Author
@alexjrk alexjrk Feb 11, 2025

Choose a reason for hiding this comment

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

A better method name for what you want might be something like is_retriable(), as it suggests checking whether a retry is possible, rather than just determining if a response is of a retry type.

Copy link
@D-stefaang D-stefaang Apr 14, 2025

Choose a reason for hiding this comment

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

Having both the is_retry and is_retriable method on the Retry object would be a bit confusing.
But this is being tackled in #2500 though with is_response_retry

alexjrk and others added 2 commits February 11, 2025 16:17
Co-authored-by: D-stefaang <58431810+D-stefaang@users.noreply.github.com>
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.

Retry.get_retry_after does't respect time-out
4 participants
0