Skip to content

TDL-16648: Implement request timeouts #129

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

Merged
merged 11 commits into from
Jan 13, 2022

Conversation

hpatel41
Copy link
Contributor

@hpatel41 hpatel41 commented Dec 7, 2021

Description of change

TDL-16648: Implement request timeouts

  • Added request timeout for the tap, default timeout is 300 seconds.

QA steps

  • automated tests passing
  • manual qa steps passing (list below)

Risks

Rollback steps

  • revert this branch

self.request_timeout = REQUEST_TIMEOUT # set default timeout
timeout_from_config = Context.config.get('request_timeout')
# updated the timeout value if timeout is passed in config and not from 0, "0", ""
if timeout_from_config and float(timeout_from_config):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to write this code 2 times, can't we put this inside one function and use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a function that returns the timeout value.

# verify the timeout is set as expected
self.assertEquals(stream.request_timeout, 100)

def test_timeout_empty_value_passed_in_config(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add function comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@hpatel41 hpatel41 requested a review from dbshah1212 January 5, 2022 12:34
This function checks whether the error contains 'timed out' substring and return boolean
values accordingly, to decide whether to backoff or not.
"""
def gen_fn(exc):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need inner function? OR one function is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used 1 function for giveup condition.


@shopify_error_handling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove this, isn't it required for other error handling?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have added the decorator over the find method. Hence removed this decorator.


@shopify_error_handling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove this, isn't it required for other error handling?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have added the decorator over the find method. Hence removed this decorator.

@hpatel41 hpatel41 requested a review from dbshah1212 January 10, 2022 13:27
@backoff.on_exception(backoff.expo, # timeout error raise by Shopify
(pyactiveresource.connection.Error, socket.timeout),
giveup=is_timeout_error,
max_tries=MAX_RETRIES,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshpatel4crest Don't we have to use retry_after_wait_gen function to wait for the next retry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the code, retry_after_wait_gen is used for the request error that contains the header in the error response.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so retry_after_wait_gen will be used in case of Errors like 429 (Max retries). Got it, Thank you

path: test_output/report.xml
- store_artifacts:
path: htmlcov
- add_ssh_keys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this add_ssh_keys line is necessary

@KrisPersonal KrisPersonal merged commit cb50ba6 into master Jan 13, 2022
tmck-code pushed a commit to lexerdev/tap-shopify that referenced this pull request Feb 3, 2022
* added request timeout

* resolve pylint error

* resolve integration test failure

* resolve pylint error

* changed 5 with MAX_RETRIES

* added request timeout in discovery call

* added socket timeout error backoff

* created a function to return timeout value

* updated the backoff to use 1 function for giveup

* resolve pylint error
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.

5 participants