TDL-26714: Fix ratelimit error and add retry for 5xx errors#155
Merged
Conversation
prijendev
commented
Nov 20, 2024
| try: | ||
| response_json = await response.json() | ||
| except (ContentTypeError, ValueError) as e: | ||
| LOGGER.warning("Error decoding response from API. Exception: %s", e, exc_info=True) |
Contributor
Author
There was a problem hiding this comment.
For every non-200 error, API does not return a valid JSON response. Showing, logger with stack trace make it very ugly.
RushiT0122
reviewed
Nov 25, 2024
| ticket_ids = [] | ||
| # Write state after processing the batch. | ||
| singer.write_state(state) | ||
| counter+=CONCURRENCY_LIMIT |
Contributor
There was a problem hiding this comment.
Suggested change
| counter+=CONCURRENCY_LIMIT | |
| counter += CONCURRENCY_LIMIT |
RushiT0122
reviewed
Nov 25, 2024
Comment on lines
+339
to
+340
| # Add 2 seconds of buffer time | ||
| time.sleep(max(0, 60 - (time.time() - start_time)+2)) |
Contributor
There was a problem hiding this comment.
Though original code logic is correct, suggested code may offer better readability, clarity and code maintenance.
Suggested change
| # Add 2 seconds of buffer time | |
| time.sleep(max(0, 60 - (time.time() - start_time)+2)) | |
| # Calculate elapsed time | |
| elapsed_time = time.time() - start_time | |
| # Calculate remaining time until the next minute, plus buffer | |
| remaining_time = max(0, 60 - elapsed_time + 2) | |
| # Sleep for the calculated time | |
| time.sleep(remaining_time) |
RushiT0122
reviewed
Nov 25, 2024
Contributor
RushiT0122
left a comment
There was a problem hiding this comment.
Left some suggestiosn.
vishalp-dev
approved these changes
Nov 26, 2024
Contributor
Author
Addressed all your comments |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of change
Manual QA steps
Risks
Rollback steps
AI generated code
https://internal.qlik.dev/general/ways-of-working/code-reviews/#guidelines-for-ai-generated-code