(self, bucket_name, attempts=5, delay=5)
| 922 | return response |
| 923 | |
| 924 | def delete_bucket(self, bucket_name, attempts=5, delay=5): |
| 925 | self.remove_all_objects(bucket_name) |
| 926 | client = self.create_client_for_bucket(bucket_name) |
| 927 | |
| 928 | # There's a chance that, even though the bucket has been used |
| 929 | # several times, the delete will fail due to eventual consistency |
| 930 | # issues. |
| 931 | attempts_remaining = attempts |
| 932 | while True: |
| 933 | attempts_remaining -= 1 |
| 934 | try: |
| 935 | client.delete_bucket(Bucket=bucket_name) |
| 936 | break |
| 937 | except client.exceptions.NoSuchBucket: |
| 938 | if self.bucket_not_exists(bucket_name): |
| 939 | # Fast fail when the NoSuchBucket error is real. |
| 940 | break |
| 941 | if attempts_remaining <= 0: |
| 942 | raise |
| 943 | time.sleep(delay) |
| 944 | |
| 945 | self.regions.pop(bucket_name, None) |
| 946 | |
| 947 | def remove_all_objects(self, bucket_name): |
| 948 | client = self.create_client_for_bucket(bucket_name) |
no test coverage detected