3
3
import datetime
4
4
import itertools
5
5
import logging
6
- import time
7
6
from typing import Any , Dict , List , Optional , Union
8
- from urllib .parse import unquote_plus as _unquote_plus
9
7
10
8
import boto3
11
9
12
- from awswrangler import _utils , exceptions
10
+ from awswrangler import _utils
13
11
from awswrangler ._threading import _get_executor
14
12
from awswrangler .distributed import ray_remote
15
13
from awswrangler .s3 ._fs import get_botocore_valid_kwargs
@@ -36,9 +34,11 @@ def _delete_objects(
36
34
bucket : str ,
37
35
keys : List [str ],
38
36
s3_additional_kwargs : Optional [Dict [str , Any ]],
39
- attempt : int = 1 ,
40
37
) -> None :
41
- client_s3 : boto3 .client = _utils .client (service_name = "s3" , session = boto3_session )
38
+ client_s3 : boto3 .client = _utils .client (
39
+ service_name = "s3" ,
40
+ session = boto3_session ,
41
+ )
42
42
_logger .debug ("len(keys): %s" , len (keys ))
43
43
batch : List [Dict [str , str ]] = [{"Key" : key } for key in keys ]
44
44
if s3_additional_kwargs :
@@ -51,24 +51,6 @@ def _delete_objects(
51
51
deleted : List [Dict [str , Any ]] = res .get ("Deleted" , [])
52
52
for obj in deleted :
53
53
_logger .debug ("s3://%s/%s has been deleted." , bucket , obj .get ("Key" ))
54
- errors : List [Dict [str , Any ]] = res .get ("Errors" , [])
55
- internal_errors : List [str ] = []
56
- for error in errors :
57
- _logger .debug ("error: %s" , error )
58
- if "Code" not in error or error ["Code" ] != "InternalError" :
59
- raise exceptions .ServiceApiError (errors )
60
- internal_errors .append (_unquote_plus (error ["Key" ]))
61
- if len (internal_errors ) > 0 :
62
- if attempt > 5 : # Maximum of 5 attempts (Total of 15 seconds)
63
- raise exceptions .ServiceApiError (errors )
64
- time .sleep (attempt ) # Incremental delay (linear)
65
- _delete_objects (
66
- bucket = bucket ,
67
- keys = internal_errors ,
68
- boto3_session = boto3_session ,
69
- s3_additional_kwargs = s3_additional_kwargs ,
70
- attempt = (attempt + 1 ),
71
- )
72
54
73
55
74
56
def delete_objects (
0 commit comments