-
Notifications
You must be signed in to change notification settings - Fork 449
fix: Fix retry count to not count the original request #1328
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
Conversation
'https://c.placeholder.com', | ||
'https://b.placeholder.com', | ||
'https://b.placeholder.com', | ||
'https://b.placeholder.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intenational?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, default retries are 3. So now with this PR it will make 4 calls (original request + 3 retries)
'https://c.placeholder.com', | ||
'https://c.placeholder.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intenational?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, 1 retry means 1 call + 1 retry.
# Retrieve or initialize the headers, and extract the current custom retry count. | ||
headers = context.request.headers or HttpHeaders() | ||
custom_retry_count = int(headers.get('custom_retry_count', '0')) | ||
|
||
# Append the current call information. | ||
calls.append(Call(context.request.url, error, custom_retry_count)) | ||
|
||
# Update the request to include an incremented custom retry count in the headers and return it. | ||
request = context.request.model_dump() | ||
request['headers'] = HttpHeaders({'custom_retry_count': str(custom_retry_count + 1)}) | ||
return Request.model_validate(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just some optimization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this was somewhat complicated for the test's intention, and the same could be achieved with a simpler setup.
Just curious, is there a test that checks this in the JS version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I think this should cover it |
The argument `max_request_retries` of `BasicCrawler` previously included also the initial request in retries. Now it counts only the retries. - Closes: #1326
Description
The argument
max_request_retries
ofBasicCrawler
previously included also the initial request in retries. Now it counts only the retries.Issues