Repository navigation
fix(web, audit_logs, scim, webhook): pass the status error to async retry handlers #2080
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b11359
fix(web, audit_logs, scim, webhook): pass the status error to async r…
WilliamBergamin 9e7fcbd
refactor(http_retry): take the async status error from raise_for_status
WilliamBergamin 788588d
refactor(web, audit_logs, scim, webhook): catch the async status erro…
WilliamBergamin 55c2cf0
fix(http_retry): only skip async status errors that have a response
WilliamBergamin cdfa3d0
refactor(web): use one async retry handler loop
WilliamBergamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from typing import List, Optional | ||
|
|
||
| from aiohttp import ClientResponseError | ||
|
|
||
| from slack_sdk.http_retry.builtin_async_handlers import AsyncServerErrorRetryHandler | ||
| from slack_sdk.http_retry.builtin_interval_calculators import FixedValueRetryIntervalCalculator | ||
| from slack_sdk.http_retry.state import RetryState | ||
| from slack_sdk.http_retry.request import HttpRequest | ||
| from slack_sdk.http_retry.response import HttpResponse | ||
|
|
||
|
|
||
| class ErrorRecordingRetryHandler(AsyncServerErrorRetryHandler): | ||
| def __init__(self): | ||
| super().__init__(max_retry_count=1, interval_calculator=FixedValueRetryIntervalCalculator(0)) | ||
| self.can_retry_errors: List[Optional[Exception]] = [] | ||
| self.prepare_errors: List[Optional[Exception]] = [] | ||
|
|
||
| async def _can_retry_async( | ||
| self, | ||
| *, | ||
| state: RetryState, | ||
| request: HttpRequest, | ||
| response: Optional[HttpResponse] = None, | ||
| error: Optional[Exception] = None, | ||
| ) -> bool: | ||
| self.can_retry_errors.append(error) | ||
| return await super()._can_retry_async(state=state, request=request, response=response, error=error) | ||
|
|
||
| async def prepare_for_next_attempt_async( | ||
| self, | ||
| *, | ||
| state: RetryState, | ||
| request: HttpRequest, | ||
| response: Optional[HttpResponse] = None, | ||
| error: Optional[Exception] = None, | ||
| ) -> None: | ||
| self.prepare_errors.append(error) | ||
| await super().prepare_for_next_attempt_async(state=state, request=request, response=response, error=error) | ||
|
|
||
|
|
||
| def error_statuses(errors: List[Optional[Exception]]) -> List[object]: | ||
| return [error.status if isinstance(error, ClientResponseError) else error for error in errors] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
suggestion (non-blocking): The two handler loops only differ by
error=e, so we could start witherror = None, assign it in theexcept, and keep one loop that passeserror=error. One copy is easier to keep in step with the other three clients.