-
Notifications
You must be signed in to change notification settings - Fork 128
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
new:dev:SDK-386:Add Retries and Delay Options in python-sdk #295
Conversation
qds_sdk/qubole.py
Outdated
@@ -21,6 +21,8 @@ class Qubole: | |||
""" | |||
|
|||
MIN_POLL_INTERVAL = 1 | |||
RETRIES_CAP = 6 |
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.
Calculated the values as follow-
With backoff factor as 2 and retry count of 6, we will be retrying 5 times, till the retry_count is >1, decrementing it on each retry. Keeping base_delay as 10sec,
Thus, all retries will be completed within
10 + 20 + 40 + 80 + 160 = 310sec (around 5 minutes)
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.
Looks good to me now.
bin/qds.py
Outdated
optparser.add_option("--max_retries", dest="max_retries", | ||
type=int, | ||
default=os.getenv('QDS_MAX_RETRIES'), | ||
help="Number of re-attempts for an api-call in case of retryable exceptions. defaults to 6." |
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.
This should be 5, please propogate the change in other code places as well. Handle this in the loop if needed.
@@ -50,20 +53,45 @@ def __init__(self, auth, rest_url, skip_ssl_cert_check, reuse=True): | |||
self.session_with_retries = requests.Session() | |||
self.session_with_retries.mount('https://', MyAdapter(max_retries=3)) | |||
|
|||
@retry((RetryWithDelay, requests.Timeout, ServerError), tries=6, delay=30, backoff=2) | |||
def retry(ExceptionToCheck, tries=5, delay=10, backoff=2): | |||
def deco_retry(f): |
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.
can we add some unit tests for this method? As the retry logic isn't very straightforward anymore.
@shekharsaurabh , please merge the latest unreleased to your branch so that we can merge the changes. |
As part of API throttling phase-2 dev, we are extending the capability to add retries and delay options for the user which can be consumed in case of RetryableExceptions.