-
Notifications
You must be signed in to change notification settings - Fork 38
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
TDL-26714: Fix ratelimit error and add retry for 5xx errors #155
Conversation
try: | ||
response_json = await response.json() | ||
except (ContentTypeError, ValueError) as e: | ||
LOGGER.warning("Error decoding response from API. Exception: %s", e, exc_info=True) |
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.
For every non-200 error, API does not return a valid JSON response. Showing, logger with stack trace make it very ugly.
tap_zendesk/streams.py
Outdated
@@ -327,6 +331,15 @@ def emit_sub_stream_metrics(sub_stream): | |||
ticket_ids = [] | |||
# Write state after processing the batch. | |||
singer.write_state(state) | |||
counter+=CONCURRENCY_LIMIT |
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.
counter+=CONCURRENCY_LIMIT | |
counter += CONCURRENCY_LIMIT |
tap_zendesk/streams.py
Outdated
# Add 2 seconds of buffer time | ||
time.sleep(max(0, 60 - (time.time() - start_time)+2)) |
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.
Though original code logic is correct, suggested code may offer better readability, clarity and code maintenance.
# 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) |
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.
Left some suggestiosn.
Addressed all your comments |
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