Skip to content

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

Merged
chattarajoy merged 21 commits intoqubole:unreleasedfrom
shekharsaurabh:INFRA-2843_1
Jan 30, 2020
Merged

new:dev:SDK-386:Add Retries and Delay Options in python-sdk#295
chattarajoy merged 21 commits intoqubole:unreleasedfrom
shekharsaurabh:INFRA-2843_1

Conversation

@shekharsaurabh
Copy link
Copy Markdown
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.

"""

MIN_POLL_INTERVAL = 1
RETRIES_CAP = 6
Copy link
Copy Markdown
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
Copy Markdown

@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.

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."
Copy link
Copy Markdown

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.


@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
Copy Markdown
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.

@chattarajoy
Copy link
Copy Markdown
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