Skip to content

Commit

Permalink
Add error predicate.
Browse files Browse the repository at this point in the history
Addresses:
#2333 (comment)
  • Loading branch information
tseaver committed Sep 16, 2016
1 parent 17c2ec6 commit 0ac2ea5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions system_tests/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ def tearDown(self):
from google.cloud.storage import Bucket
from google.cloud.exceptions import BadRequest
from google.cloud.exceptions import Conflict
retry_400 = RetryErrors(BadRequest)

def _still_in_use(bad_request):
return any(error['reason'] == 'resourceInUse'
for error in bad_request._errors)

retry_in_use = RetryErrors(BadRequest, error_predicate=_still_in_use)
retry_409 = RetryErrors(Conflict)
for doomed in self.to_delete:
if isinstance(doomed, Bucket):
retry_409(doomed.delete)(force=True)
elif isinstance(doomed, Dataset):
retry_400(doomed.delete)()
retry_in_use(doomed.delete)()
else:
doomed.delete()

Expand Down

0 comments on commit 0ac2ea5

Please sign in to comment.