Skip to content

Commit

Permalink
Change comments, Retry class properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Aug 2, 2016
1 parent f33b2ea commit e06815d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 6 additions & 6 deletions system_tests/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def test_update_dataset(self):
if grant.entity_id != 'projectWriters']
dataset.access_grants = after

# 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 due to upstream rate limiting.
# We need to wait to stay within the rate limits.
# The alternative outcome is a 403 Forbidden response from upstream.
# See: https://cloud.google.com/bigquery/quota-policy
@Retry(Forbidden, tries=2, delay=30)
def update_dataset():
dataset.update()
Expand Down Expand Up @@ -199,9 +199,9 @@ def test_update_table(self):
dataset = Config.CLIENT.dataset(DATASET_NAME)
self.assertFalse(dataset.exists())

# 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 due to upstream rate limiting.
# We need to wait to stay within the rate limits.
# The alternative outcome is a 403 Forbidden response from upstream.
# See: https://cloud.google.com/bigquery/quota-policy
@Retry(Forbidden, tries=2, delay=30)
def create_dataset():
dataset.create()
Expand Down
6 changes: 2 additions & 4 deletions system_tests/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ def __call__(self, to_wrap):
@wraps(to_wrap)
def wrapped_function(*args, **kwargs):
tries_counter = self.tries
exception = self.exception
delay = self.delay
backoff = self.backoff
while tries_counter > 0:
try:
return to_wrap(*args, **kwargs)
except exception as caught_exception:
except self.exception as caught_exception:
msg = ("%s, Trying again in %d seconds..." %
(str(caught_exception), delay))
self.logger(msg)

time.sleep(delay)
tries_counter -= 1
delay *= backoff
delay *= self.backoff
return to_wrap(*args, **kwargs)

return wrapped_function

0 comments on commit e06815d

Please sign in to comment.