Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 batch delete #78

Open
kislyuk opened this issue Feb 19, 2025 · 0 comments
Open

S3 batch delete #78

kislyuk opened this issue Feb 19, 2025 · 0 comments

Comments

@kislyuk
Copy link
Owner

kislyuk commented Feb 19, 2025

bucket = s3.Bucket(...)
def delete_objects(objs):
    print(len(objs), objs[0])
    return bucket.delete_objects(Delete={"Objects": [{"Key": obj.key} for obj in objs]})
with ThreadPoolExecutor(max_workers=4) as executor:
    for res in executor.map(delete_objects, batched(bucket.objects.all(), 1000)):
        print(json.dumps(res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant