Skip to content
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

Merged
merged 21 commits into from
Jan 30, 2020
Merged

new:dev:SDK-386:Add Retries and Delay Options in python-sdk #295

merged 21 commits into from
Jan 30, 2020

Conversation

shekharsaurabh
Copy link
Contributor

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.

qds_sdk/qubole.py Outdated Show resolved Hide resolved
@@ -21,6 +21,8 @@ class Qubole:
"""

MIN_POLL_INTERVAL = 1
RETRIES_CAP = 6
Copy link
Contributor Author

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)

yogesh2021
yogesh2021 previously approved these changes Jan 23, 2020
Copy link

@yogesh2021 yogesh2021 left a 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.

qds_sdk/connection.py Outdated Show resolved Hide resolved
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."

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):
Copy link
Member

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.

qds_sdk/connection.py Show resolved Hide resolved
@chattarajoy
Copy link
Member

@shekharsaurabh , please merge the latest unreleased to your branch so that we can merge the changes.

@shekharsaurabh shekharsaurabh changed the title new:dev:INFRA-2843:Add Retries and Delay Options in python-sdk new:dev:SDK-386:Add Retries and Delay Options in python-sdk Jan 30, 2020
@chattarajoy chattarajoy merged commit 2c123e5 into qubole:unreleased Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants