28
28
from google .cloud .storage import Blob
29
29
from google .cloud .storage .blob import _get_host_name
30
30
from google .cloud .storage .constants import _DEFAULT_TIMEOUT
31
+ from google .cloud .storage ._helpers import _api_core_retry_to_resumable_media_retry
32
+ from google .cloud .storage .retry import DEFAULT_RETRY
31
33
32
34
from google .resumable_media .requests .upload import XMLMPUContainer
33
35
from google .resumable_media .requests .upload import XMLMPUPart
@@ -871,6 +873,7 @@ def upload_chunks_concurrently(
871
873
* ,
872
874
checksum = "md5" ,
873
875
timeout = _DEFAULT_TIMEOUT ,
876
+ retry = DEFAULT_RETRY ,
874
877
):
875
878
"""Upload a single file in chunks, concurrently.
876
879
@@ -966,6 +969,20 @@ def upload_chunks_concurrently(
966
969
(Optional) The amount of time, in seconds, to wait
967
970
for the server response. See: :ref:`configuring_timeouts`
968
971
972
+ :type retry: google.api_core.retry.Retry
973
+ :param retry: (Optional) How to retry the RPC. A None value will disable
974
+ retries. A google.api_core.retry.Retry value will enable retries,
975
+ and the object will configure backoff and timeout options. Custom
976
+ predicates (customizable error codes) are not supported for media
977
+ operations such as this one.
978
+
979
+ This function does not accept ConditionalRetryPolicy values because
980
+ preconditions are not supported by the underlying API call.
981
+
982
+ See the retry.py source code and docstrings in this package
983
+ (google.cloud.storage.retry) for information on retry types and how
984
+ to configure them.
985
+
969
986
:raises: :exc:`concurrent.futures.TimeoutError` if deadline is exceeded.
970
987
"""
971
988
@@ -995,6 +1012,8 @@ def upload_chunks_concurrently(
995
1012
headers ["x-goog-encryption-kms-key-name" ] = blob .kms_key_name
996
1013
997
1014
container = XMLMPUContainer (url , filename , headers = headers )
1015
+ container ._retry_strategy = _api_core_retry_to_resumable_media_retry (retry )
1016
+
998
1017
container .initiate (transport = transport , content_type = content_type )
999
1018
upload_id = container .upload_id
1000
1019
@@ -1025,6 +1044,7 @@ def upload_chunks_concurrently(
1025
1044
part_number = part_number ,
1026
1045
checksum = checksum ,
1027
1046
headers = headers ,
1047
+ retry = retry ,
1028
1048
)
1029
1049
)
1030
1050
@@ -1054,6 +1074,7 @@ def _upload_part(
1054
1074
part_number ,
1055
1075
checksum ,
1056
1076
headers ,
1077
+ retry ,
1057
1078
):
1058
1079
"""Helper function that runs inside a thread or subprocess to upload a part.
1059
1080
@@ -1075,6 +1096,7 @@ def _upload_part(
1075
1096
checksum = checksum ,
1076
1097
headers = headers ,
1077
1098
)
1099
+ part ._retry_strategy = _api_core_retry_to_resumable_media_retry (retry )
1078
1100
part .upload (client ._http )
1079
1101
return (part_number , part .etag )
1080
1102
0 commit comments