-
Notifications
You must be signed in to change notification settings - Fork 1
⚡ Bolt: Parallelize folder deletion #81
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -646,12 +646,23 @@ | |||||||||||||||
| existing_folders = list_existing_folders(client, profile_id) | ||||||||||||||||
| if not no_delete: | ||||||||||||||||
| deletion_occurred = False | ||||||||||||||||
| folders_to_delete = [] | ||||||||||||||||
| for folder_data in folder_data_list: | ||||||||||||||||
| name = folder_data["group"]["group"].strip() | ||||||||||||||||
| if name in existing_folders: | ||||||||||||||||
| delete_folder(client, profile_id, name, existing_folders[name]) | ||||||||||||||||
| deletion_occurred = True | ||||||||||||||||
|
|
||||||||||||||||
| folders_to_delete.append((name, existing_folders[name])) | ||||||||||||||||
|
|
||||||||||||||||
| if folders_to_delete: | ||||||||||||||||
| # Parallelize deletion: Use 5 workers to speed up deletions without hammering the API too hard | ||||||||||||||||
Check warningCode scanning / Pylint (reported by Codacy) Line too long (114/100) Warning
Line too long (114/100)
|
||||||||||||||||
| with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: | ||||||||||||||||
| futures = [ | ||||||||||||||||
| executor.submit(delete_folder, client, profile_id, name, folder_id) | ||||||||||||||||
| for name, folder_id in folders_to_delete | ||||||||||||||||
|
Comment on lines
+657
to
+660
|
||||||||||||||||
| ] | ||||||||||||||||
| for future in concurrent.futures.as_completed(futures): | ||||||||||||||||
| if future.result(): | ||||||||||||||||
| deletion_occurred = True | ||||||||||||||||
|
Comment on lines
+663
to
+664
|
||||||||||||||||
| if future.result(): | |
| deletion_occurred = True | |
| try: | |
| if future.result(): | |
| deletion_occurred = True | |
| except Exception as e: | |
| log.error(f"Failed to delete folder during parallel deletion: {e}") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Line too long (114/100) Warning