MaksYermak commented on code in PR #49633:
URL: https://github.com/apache/airflow/pull/49633#discussion_r2056491966
##########
providers/google/src/airflow/providers/google/cloud/operators/gcs.py:
##########
@@ -333,8 +336,20 @@ def execute(self, context: Context) -> None:
else:
objects = hook.list(bucket_name=self.bucket_name,
prefix=self.prefix)
self.log.info("Deleting %s objects from %s", len(objects),
self.bucket_name)
- for object_name in objects:
- hook.delete(bucket_name=self.bucket_name, object_name=object_name)
+
+ failed = []
+ with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
+ futures = {
+ executor.submit(hook.delete, bucket_name=self.bucket_name,
object_name=o): o for o in objects
+ }
+ for future in as_completed(futures):
+ try:
+ future.result()
+ except Exception:
+ failed.append(futures[future])
+
+ if failed:
+ raise AirflowException(f"Failed to delete {len(failed)} objects:
{failed[:10]}")
Review Comment:
For me this functionality doesn't look as optional. This code replaces the
whole current functionality with the new one and it can be critical for users.
In my opinion if you want to make this new feature optional it is better to
create a new bool variable and put this code under the `if-statement` using
this variable. Then users can choose what approach they want to use.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]