Skip to content

Commit

Permalink
Retry whole batch of deletes on 429.
Browse files Browse the repository at this point in the history
Because 'Bucket.delete' inside a batch context manager is deferred,
we cannot retry it directly.  We also need to check for bucket existence,
as the bucket *may* have been deleted in the previous batch before the
429 was raised.

Closes #3761.
  • Loading branch information
tseaver committed Sep 25, 2017
1 parent 3f3cdce commit bccc5bc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions storage/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ class TestStorageBuckets(unittest.TestCase):
def setUp(self):
self.case_buckets_to_delete = []

def tearDown(self):
def _delete_buckets(self):
with Config.CLIENT.batch():
for bucket_name in self.case_buckets_to_delete:
bucket = Config.CLIENT.bucket(bucket_name)
retry_429(bucket.delete)()
if bucket.exists():
bucket.delete()

def tearDown(self):
retry_429(self._delete_buckets)()

def test_create_bucket(self):
new_bucket_name = 'a-new-bucket' + unique_resource_id('-')
Expand Down

0 comments on commit bccc5bc

Please sign in to comment.