Skip to content

Commit

Permalink
Update s3_clean_test_bucket.py
Browse files Browse the repository at this point in the history
  • Loading branch information
albags committed Jul 16, 2024
1 parent 73a1067 commit 308afad
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions s3_clean_test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ def delete_file_from_bucket(obj):


BUCKET = s3_client.Bucket("test-upload")
PREFIX = ""

# Create a ThreadPoolExecutor
COUNT = 0

for i in BUCKET.objects.filter(Prefix=PREFIX):
for _ in BUCKET.objects.all():
COUNT = COUNT + 1

print(f"Total number of files {COUNT}\n")

# Create a ThreadPoolExecutor
with tqdm(desc="Deleting files", ncols=60, total=COUNT, unit="B", unit_scale=1) as pbar:
with ThreadPoolExecutor() as executor:
futures = [
executor.submit(delete_file_from_bucket, obj)
for obj in BUCKET.objects.filter(Prefix=PREFIX)
for obj in BUCKET.objects.all()
]
for future in as_completed(futures):
for _ in as_completed(futures):
pbar.update(1)

0 comments on commit 308afad

Please sign in to comment.