-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Playing with retries. #2040
Playing with retries. #2040
Conversation
from functools import wraps | ||
|
||
|
||
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Sorry, I should have put more in the description I think. So my point with this, was that there are a lot more errors after the main blocking bigquery error that we keep seeing. I'm sure this isn't the best solution. When I run system-tests I get a bunch of datastore failures/errors. Are there some fixtures I need to setup to get those to work? I can fix this up so we can merge and go from there though. |
There is nothing wrong with the retry method, it just looks copy-pasted. You'd probably rather use it inside the test case than on the test case: def test_case_for_thing(self):
# do some set-up
@retry(...)
def thing_that_is_eventually_consistent():
global_object.some_method(args)
thing_that_is_eventually_consistent() |
067e147
to
2dc08cf
Compare
@dhermes LMKWYT. |
|
||
@retry(Forbidden, tries=3, delay=30) | ||
def update_dataset(): | ||
dataset.update() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Thanks for taking the initiative here. Searching In particular, we should discuss this in #1619 |
|
||
# We should try and keep `delay` and tries as low as possible to | ||
# reduce test running time. tries=3 and delay=30 worked consistenly | ||
# when updating a dataset. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@dhermes here's the class version of the retry decorator. LMWYT. |
exception = None | ||
tries = None | ||
delay = None | ||
backoff = None |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
time.sleep(self.delay) | ||
tries_counter -= 1 | ||
self.delay *= self.backoff |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
874cf22
to
c532444
Compare
|
||
# We need to wait for the changes in the dataset to propgate and be | ||
# eventually consistent. The alternative outcome is a 403 Forbidden | ||
# response from upstream. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
090b734
to
f33b2ea
Compare
tries_counter = self.tries | ||
exception = self.exception | ||
delay = self.delay | ||
backoff = self.backoff |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM pending Travis |
So I was playing with getting the retries working on the bigquery system3 tests.
I'm not sure what fixtures need to be created to get all the tests passing but this seemed to get the bigquery tests to pass.
Also, I have the retry set pretty long, looks like it takes about an average of 20 seconds for it to eventually be consistent.